Results 1 to 6 of 6
  1. #1
    luciawashaya is offline Member
    Join Date
    Oct 2011
    Posts
    11
    Rep Power
    0

    Default help with multidimesional array qn

    b) Given two equal sized double arrays : X, Y initialized with some non sorted numbers, and a third equal sized boolean array Z . Write a Java method to check the equality of corresponding elements of array X and Y elements , and put the result into the corresponding index element of boolean array Z . [10 marks]

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default Re: help with multidimesional array qn

    So, Z[j]= X[j] == Y[j]? If so, put a loop around it and pass me the 10 marks.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    luciawashaya is offline Member
    Join Date
    Oct 2011
    Posts
    11
    Rep Power
    0

    Default Re: help with multidimesional array qn

    public boolean findMacthes([][]x,[][]y){
    if([][]x!=[][]y){

    return null;
    }
    for(int a = 0;a<x.length;a++){
    for(int c = 0 ;c<y.length;c++){
    result [a][c] = true;
    }
    }
    }
    return result;
    }

  4. #4
    luciawashaya is offline Member
    Join Date
    Oct 2011
    Posts
    11
    Rep Power
    0

    Default Re: help with multidimesional array qn

    public boolean findMacthes([][]x,[][]y){
    if([][]x!=[][]y){

    return null;
    }
    boolean [][]Z=new boolean [x.length,y.length]
    for(int a = 0;a<x.length;a++){
    for(int c = 0 ;c<y.length;c++){
    Z[a][c] = true;
    }
    }
    }
    return z[][];
    }

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default Re: help with multidimesional array qn

    Did your compiler like it? I guess not; don't just guess what the Java language should be in your imagination; read a textbook.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    4

    Default Re: help with multidimesional array qn

    Check if x[index] == y[index], if true z[index] = true else z[index] false.
    You don't need a nested loop, and as JosAH said, read a textbook it's not looks like Java.

Similar Threads

  1. How to convert array of Objects into array of Strings
    By elenora in forum Advanced Java
    Replies: 1
    Last Post: 06-10-2011, 03:48 PM
  2. Replies: 0
    Last Post: 05-12-2011, 07:04 PM
  3. Replies: 23
    Last Post: 09-07-2010, 08:12 PM
  4. Replies: 2
    Last Post: 09-06-2010, 01:03 AM
  5. Replies: 1
    Last Post: 03-31-2009, 06: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
  •