View RSS Feed

My Java Tips

Wrapping Strings

Rate this Entry
by , 05-21-2011 at 10:50 PM (3525 Views)
Its always useful to wrap strings if they are too long. This provides better readability. Eclipse has support for this.

String literals can wrapped when you edit them. Place your cursor at the point of literal where you want to wrap and press Enter. For example:

Java Code:
String message= "Java is fun to learn and it sure is a popular programming language.";
I kept the cursor at ‘sure’ and pressed enter key. The String was changed to:

Java Code:
String message= "Java is fun to learn and it sure” +
 “is a popular programming language.";
This behavior can be customized in the "Java > Editor > Typing" preference page.

Submit "Wrapping Strings" to Facebook Submit "Wrapping Strings" to Digg Submit "Wrapping Strings" to del.icio.us Submit "Wrapping Strings" to StumbleUpon Submit "Wrapping Strings" to Google

Tags: string Add / Edit Tags
Categories
Eclipse

Comments