java beginners doubt!

Ads
 

java beginners doubt!

How to write clone()in java strings?

View Answers

June 18, 2011 at 12:06 PM

class StringClone{
    public static void main(String[] args) 
    {
String [] fruits ={"Apple","Mango","Grapes","Banana","Guava"};
  String [] fruits2 = (String []) fruits.clone ();
for (int i = 0; i < fruits.length; i++){
     fruits2 [i] = new String (fruits [i]);
     System.out.println(fruits2[i]);
    }

    }
}

Ads









Related Tutorials/Questions & Answers:

Ads