Results 1 to 2 of 2
  1. #1
    smokinjoachim is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default Double the size of a 2d

    I am trying to double the size of a array. My code is below, it is now working when it prints it is just printing zeros, it is isn't copying the values. Any help would be greatly appreciated.

    public static int [][] double2D(int [][]twoD)
    {
    //int [][] superArray = twoD.length*2;
    int [][] superArray = new int[1][1];
    for(int i = 0; i < twoD.length; i++)
    {
    for(int j = 0; j < twoD[i].length; j++)
    {
    superArray = new int[i*2][j*2];
    superArray[i][j] = twoD[i][j];

    }
    }
    return superArray;
    }

  2. #2
    smokinjoachim is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default A little progress

    So i worked on the code a little and this is what i came up with, it works if twoD is 5,6 but if it is 5,7 it does not work.

    public static int [][] double2D(int [][]twoD)
    {
    int [][] superArray = new int[twoD.length*2][twoD.length + 1];
    for(int i = 0; i < twoD.length; i++)
    {
    for(int j = 0; j < twoD[i].length; j++)
    {
    superArray[i][j] = twoD[i][j];
    }

    }
    return superArray;
    }

Similar Threads

  1. double a * double b = weird output
    By GPB in forum New To Java
    Replies: 3
    Last Post: 03-26-2010, 11:40 AM
  2. Check if double is double
    By marshalthrone in forum New To Java
    Replies: 8
    Last Post: 09-30-2009, 03:51 PM
  3. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 05:37 PM
  4. Replies: 5
    Last Post: 03-21-2009, 10:32 PM
  5. Double.valueOf() vs Double.parseDouble()
    By greenbean in forum New To Java
    Replies: 10
    Last Post: 01-12-2009, 09:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •