Eclipse: Convert String Concat to StringBuilder

Here is a simple yet effective trick for all Eclipse users. In Java we do lot of String concatenation using plain old “” + “”. It is easy but not too effective. StringBuilder is always preferred if you have too many strings to concate.


In below screencast, I convert concatenated strings to StringBuilder using eclipse Ctrl + 1 option.

eclipse-string-concatenate-stringbuilder


Move cursor on String “foo” and press Ctrl + 1. It opens a context menu. Select option Use “StringBuilder” for string concatenation



String foo = "This" + "is" + "Sparta";

System.out.println(foo);

Once done, the code will be converted to below:



StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("This");
stringBuilder.append("is");
stringBuilder.append("Sparta");
String foo = stringBuilder.toString();

System.out.println(foo);

Enjoy :)








via ViralPatel.net http://feedproxy.google.com/~r/viralpatelnet/~3/31caPuoFL5s/

Older Mac webcams can spy without activating warning light, researchers find

Steam Machine prototype teardown reveals a tinkerer's delight

How to share Internet service with your neighbors, and why you shouldn't

Second season of Netflix's House of Cards will stream in 4K... sometimes

You're going to need a new TV to see Kevin Spacey scheme in glorious pixel-packed 4K resolution.



via PCWorld http://www.techhive.com/article/2081846/second-season-of-netflixs-house-of-cards-will-stream-in-4k-sometimes.html#tk.rss_all

Target says 40 million cards likely skimmed in security breach

You won't believe how much you'll pay for a maxed-out Mac Pro

Windows 11 Insider Preview Build 29558.1000 Released to New Canary Channel

UPDATE: Windows 11 Insider Preview build 29558.1000 released to the new Canary channel. Windows Insiders on the refreshed Canary Channel wil...