Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-14-2008, 09:46 PM
Java Tip's Avatar
Moderator
 
Join Date: Nov 2007
Posts: 1,691
Rep Power: 5
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Default How to clone an Array
Code:
public class CloneArray {
  public static void main(String args[]) {
    int array1[] = { 1, 2, 3, 4, 5 };
    int array2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    System.out.println("Original size: " + array1.length);
    System.out.println("New size: " + cloneArray(array1).length);
    System.out.println("Original size: " + array2.length);
    System.out.println("New size: " + cloneArray(array2).length);
  }

  static int[] cloneArray(int original[]) {
    return (int[]) original.clone();
  }
}
__________________
"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
An nslookup clone in Java Java Tip java.net 0 04-07-2008 09:12 PM
clone method javaplus New To Java 2 01-30-2008 10:47 AM
clone method gapper New To Java 1 01-20-2008 09:46 AM
clone problem feniger New To Java 13 01-13-2008 11:55 AM
How to clone a JAXB object ? simon Advanced Java 1 07-15-2007 12:56 AM


All times are GMT +2. The time now is 04:40 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org