Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4395127

clone method in single dimentional array differs from double dimentional array

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.3.0
    • tools
    • x86
    • windows_95



      Name: yyT116575 Date: 12/05/2000


      compiles and runs fine but behaviour seems incosistent.

      class aa{
      public static void main(String arg[])
      {
      int arr[]={1,2,3};
      int arrclone[]=(int[])arr.clone();
      arr[0]=100;
      System.out.println(arr[0]);// op: is 100
      System.out.println(arrclone[0]);// op: is 1

      int arr2[][]=
      {
      {1,2,3},
      {4,5,6}
      };
      int arr2clone[][]=(int[][])arr2.clone();

      arr2[0][0]=100;
      System.out.println(arr2[0][0]);// op: is 100
      System.out.println(arr2clone[0][0]);// op: is 100
      // why does it behave differently for double dimentional arrays???
      //when compared to single dimentional arrays..
      }
      }
      (Review ID: 113281)
      ======================================================================

            gafter Neal Gafter (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: