Search your topic here

String program 3

public class buf {

            /**
             * @param args
             */
            public static void main(String[] args) {
                        // TODO Auto-generated method stub
String foo = "foo";
String s = "abc" + foo + "def" + Integer.toString(47);
System.out.println(s);
//The equivalent using StringBuffer;
StringBuffer sb = new StringBuffer("abc"); // Creates String;
sb.append(foo);
sb.append("def"); //Creates a string
sb.append(Integer.toString(47));
System.out.println(sb);


            }


}

LEAVE A REPLY