tabs - Java code indentation -
for 'case 1' below, console prints text intended.
case 1: system.out.println ("text text text text text text text text text text text text text text text text text text text text text text "); break;
however, want format code that, when reading code, second line of text aligned first: s in 'system' aligned t of 'text' @ start of second line of text. if use tab indent second line, tab appears in text printed console. there way around this?
java has "+" operator strings concat multiple strings together. however, string concat using "+" known cause performance issues. hence, better save entire string single string instead of splitting readability.
case 1:       system.out.println ("text text text text" +                          " text text text text" +                          " text text text text text ");       break;   if particular, can consider stringbuffer or stringbuilder has better performance "+".
using stringbuffer, can like,
case 1:       system.out.println ( new stringbuffer                                  (" text text text text")                            .append (" text text text text")                            .append (" text text text text")  );       break;      
Comments
Post a Comment