Sunday 18 September 2016

Mutable

Mutable

What is Mutable ?
  • Once if we create a StringBuffer object we can perform any changes in the existing object, StringBuffer object is changeable, this behavior is called mutable.
-------------------------------------------------------------------
Program         :        Program on mutable nature
Program name  :        MutableDemo1.java
Output             : 
                                JavaLanguage

class MutableDemo1
{
public static void main(String args[])
{
        StringBuffer s1 = new StringBuffer("Java");
        s1.append("Language");

        System.out.println(s1);
}
}

Compile          :          javac MutableDemo1.java
Run                :          java MutableDemo1
Output            :
                                 JavaLanguage
-------------------------------------------------------------------

Thanks for your time.
                                                                                 Nireekshan