Pages

Create mutable String

In java when you create a String, it's mean you create an immutable String. You cannot change it, after you create it. Complete source code below will show you, how to create a mutable String using StringBuffer class.

***********************************************************************
COMPLETE SOURCE CODE FOR : CreateMutableString.java
***********************************************************************


public class CreateMutableString
{
public static void main(String[]args)
{
//Create a mutable String
StringBuffer a=new StringBuffer("Hi everyone");

//Print the created String
System.out.println(a);
}
}


***********************************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************************
Related Posts Plugin for WordPress, Blogger...