String concatenation, + operator, string conversion, toString method in Java

String concatenation: + operator is used to concatenate two or more strings in Java.

For Example:

String what = “Process”;

String s = “More ” + what + “in Java”;



More Process in Java

For string concatenation you can use any data type with a string type. Other data types will automatically be convert to a string object before + operator is applied.

String conversion: toString method is used for string conversion of any given object. Usually sub classes override this method. By overriding the toString method, string conversion can be used in print( ), println( ), and concatenation statements.


String toString( )

Leave a Reply