Results 1 to 6 of 6

Thread: MultiD arrays

  1. #1
    kintaru is offline Member
    Join Date
    May 2012
    Posts
    7
    Rep Power
    0

    Default MultiD arrays HELP!!

    hi every body,

    i just can't figure out the problem here, i ve tried the very same code with a simple array instead of multi and it works:

    /** Multidimentional + copy
    */
    class ArrayComplicatedSomeHow {
    public static void main (String[] args){
    //declaring the multi dim arrays
    char [][] copyFrom ={ {'a', 'b', 'c', 'd', 'e' },
    {'1', '2', '3', '4', '5' }
    };
    char [][] copyTo = new char[5][5];

    System.arraycopy(copyFrom[0],0, copyTo[0], 0, copyFrom.length);
    System.out.println(new String(copyTo));

    }
    }

    c:\classes\tutorial\Lesson>javac ArrayComplicatedSomeHow.java
    ArrayComplicatedSomeHow.java:12: error: no suitable constructor found for String
    (char[][])
    System.out.println(new String(copyTo));
    ^
    constructor String.String(int,int,char[]) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(StringBuilder) is not applicable
    (actual argument char[][] cannot be converted to StringBuilder by method i
    nvocation conversion)
    constructor String.String(StringBuffer) is not applicable
    (actual argument char[][] cannot be converted to StringBuffer by method in
    vocation conversion)
    constructor String.String(byte[]) is not applicable
    (actual argument char[][] cannot be converted to byte[] by method invocati
    on conversion)
    constructor String.String(byte[],int,int) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(byte[],Charset) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(byte[],String) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(byte[],int,int,Charset) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(byte[],int,int,String) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(byte[],int) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(byte[],int,int,int) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(int[],int,int) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(char[],int,int) is not applicable
    (actual and formal argument lists differ in length)
    constructor String.String(char[]) is not applicable
    (actual argument char[][] cannot be converted to char[] by method invocati
    on conversion)
    constructor String.String(String) is not applicable
    (actual argument char[][] cannot be converted to String by method invocati
    on conversion)
    constructor String.String() is not applicable
    (actual and formal argument lists differ in length)
    1 error
    Last edited by kintaru; 05-16-2012 at 02:54 PM.

  2. #2
    kintaru is offline Member
    Join Date
    May 2012
    Posts
    7
    Rep Power
    0

    Default Re: MultiD arrays

    I ve actually found the problem but i wonder how to output my content using String when i have a multidimensional array?
    i tired the same technic with a simple array: System.out.println(new String(myArray)); and it worked

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,736
    Rep Power
    29

    Default Re: MultiD arrays

    how to output my content using String
    Depends on the number of dimensions. Nested loops always work.
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,045
    Rep Power
    23

    Default Re: MultiD arrays

    You've already been told about the code tags. Now how about putting that knowledge to use?
    http://www.java-forums.org/new-java/...tml#post285977

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    kintaru is offline Member
    Join Date
    May 2012
    Posts
    7
    Rep Power
    0

    Default Re: MultiD arrays

    M sorry Darry ve forgot

  6. #6
    kintaru is offline Member
    Join Date
    May 2012
    Posts
    7
    Rep Power
    0

Similar Threads

  1. Copying Single Arrays to 2-D Arrays
    By jmscarlet9 in forum New To Java
    Replies: 7
    Last Post: 04-02-2012, 11:17 PM
  2. Casting Enum Type arrays to object type arrays
    By nmvictor in forum Advanced Java
    Replies: 4
    Last Post: 02-17-2012, 01:49 PM
  3. arrays and multidimensional arrays
    By belfast09 in forum New To Java
    Replies: 5
    Last Post: 06-14-2011, 01:28 PM
  4. store array of arrays in array of arrays
    By joost_m in forum New To Java
    Replies: 4
    Last Post: 04-19-2010, 10:32 AM
  5. Arrays.sort... why sorting all arrays in class?
    By innspiron in forum New To Java
    Replies: 6
    Last Post: 03-23-2010, 02:40 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
  •