Code Examples
package com.javaninja.stringexamples;
public class StringExample4 {
//Difference between String Buffer and String
public static void main (String args[])
{
String str1 = "Java";
System.out.println("str1 : "+str1);// Prints Java
str1.toUpperCase();
System.out.println("str1 after uppercase: "+str1);// Prints Java
StringBuffer sb = new StringBuffer("Java");
System.out.println("sb : "+sb);// Prints Java
sb.append(" Hello");
System.out.println("sb after append: "+sb);// Prints Java Hello
}
}
No comments:
Post a Comment