Remove empty lines from java
1,Install notepad ++
2,Download TextFx plugin
3,Unzip & copy dll file to Program Files\Notepad++\plugins
4,Open Notepad++
5,In menu >TextFX > TextFX Edit > Delete Blank Lines
Remove spaces from eclipse.Remove empty lines from java,Remove empty lines from notepad
String Tokenizer |String Splitter | Java Tutorial
The string tokenizer class allows an application to break a string into tokens. The tokenization method is much simpler than the one used by the
String Tokenizer Tutorial video
StreamTokenizer
class. The StringTokenizer
methods do not distinguish among identifiers, numbers, and quoted strings, nor do they recognize and skip comments.String Tokenizer Tutorial video
Create GUI Java Swing using Eclipse
Right-click on the Eclipse project in the Package Explorer
• On the context menu select “New / Class”.
• Set ‘Source folder’ to Calculator/src
• Set the ‘Package’ to calculator.
• Set the ‘Name’ to View
• Set Modiļ¬ers to public
• Set Superclass to javax.swing.JFrame
• Click fnish
Now open GUI class and bottom tab switch to Design
Tags:Create GUI Java Swing using Eclipse,Create GUI using Eclipse,Create GUI using Eclipse Tutorial,Create GUI in eclipse ide,Create Java swing using Eclipse
Add spaces in a String using Java
If u would like to print String "123" as "1 2 3" then follow this code.
yourString.replace("", " ").trim();
Above code just replacing all empty place with Space & remove starting space with trim method
Add leading zeros for binary conversion in java
If u convert Decimal 15 to binary,you will get Binary 1110 So you may want to add leading zero Ex:00001110
Step1:Find how many zeros do you need ?
if your input is16 then log2 16=4 zeros
if your input is 15 then log2 15=3 zeros not correct :-) So check 3 mod 2 !=0 and add one to it 3+1=4
int zeros=0;
zeros=(int) (Math.log(input)/ Math.log(2));
if (zeros%2!=0) zeros=zeros+1;
Step2:Add these zeros to your binary output
String formatted=String.format("%0"+zeros+"d\n", Integer.parseInt(Integer.toBinaryString(count)));
System.out.println(formatted);
Step1:Find how many zeros do you need ?
if your input is16 then log2 16=4 zeros
if your input is 15 then log2 15=3 zeros not correct :-) So check 3 mod 2 !=0 and add one to it 3+1=4
int zeros=0;
zeros=(int) (Math.log(input)/ Math.log(2));
if (zeros%2!=0) zeros=zeros+1;
Step2:Add these zeros to your binary output
String formatted=String.format("%0"+zeros+"d\n", Integer.parseInt(Integer.toBinaryString(count)));
System.out.println(formatted);
logarithm base 2 calculation in java
By default java provides base 10 using In build Math class
Base 10 log
Math.log(input) ;
Math.log(input) / Math.log(2);
Base 10 log
Math.log(input) ;
Base 2 log
Math.log(input) / Math.log(2);
This methods will return values in double so if you need integer
int zeros=(int) (Math.log(input)/ Math.log(2));
Subscribe to:
Posts (Atom)