Wednesday 4 January 2017


// Construct one String from another.

class MakeString
{
   public static void main(String args[])
   {
        char c[] = {'J', 'a', 'v', 'a'};
        String str1 = new String(c);
        String str2 = new String(str1);
            System.out.println(str1);
            System.out.println(str2);
   }
}

Note

Strings are unchangeable means that the contents of the String instance cannot be changed after it has been created. However, a variable declared as a String reference can be changed to point at some other String object at any time.

0 comments:

Post a Comment

Powered by Blogger.

Stats