Anusha B
java beginners doubt!
1 Answer(s)      4 years and 2 months ago
Posted in : Java Beginners

How to write clone()in java strings?

Advertisement
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]);
    }

    }
}









Related Tutorials/Questions & Answers: