Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java string concat

// adding strings with the plus is not elegant use 'String.format()' for it
String s1 = "text1";
String s2 = "text2";
String s3 = "easy: " + s1 + " " + s2;
System.out.println( s3 );
//A "better" way to do this:
String s4 = String.format( "better: %s %s", s1, s2 );
System.out.println( s4 );
// gives:
easy: text1 text2
better: text1 text2
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #java #string #concat
ADD COMMENT
Topic
Name
6+9 =