Thursday, December 24, 2015

String Concatenation with other data type

String Concatenation with other data type:

package stringdemo;


public class StringS {
    public static void main(String[] args) {
        String s="nine:"+4+4;
        System.out.println(s);
    }
}

Here output will be like 
nine:44.
   rather than
nine:8

To get 2nd type of output we must change the 
String s="nine:"+(4+4);

This will generate the output as:
nine:8

0 comments:

Post a Comment