Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

java arrays

Name: Anonymous 2013-11-24 9:06

So im making this boolean array in Java which is the result of the logical AND operation on two boolean values from different boolean arrays. I keep getting a NullPointerException, though, and dont know why. Can anyone point me in the right direction?

code:



    public static boolean[][] boolAnd(boolean[][] tablea, boolean[][] tableb) {

        boolean[][] andtable, table1, table2;

        int row, col, smallest;

        row = (tablea.length >= tableb.length)?(tablea.length):(tableb.length);
        andtable = new boolean[row][];
        table1 = new boolean[row][];
        table2 = new boolean[row][];

        smallest = (tablea.length <= tableb.length)?(tablea.length):(tableb.length);

        for (row = 0; row < smallest; row++) {
            col = (tablea[row].length >= tableb[row].length)?(tablea[row].length):(tableb[row].length);
            andtable[row] = new boolean[col];
            table1[row] = new boolean[col];
            table2[row] = new boolean[col];
        }

        for (row = 0; row < tablea.length; row++) {
            for (col = 0; col < tablea[row].length; col++) {
                table1[row][col] = tablea[row][col];
            }
        }

        for (row = 0; row < tableb.length; row++) {
            for (col = 0; col < tableb[row].length; col++) {
                table2[row][col] = tableb[row][col];
            }
        }

        for (row = 0; row < andtable.length; row++) {
            for (col = 0; col < andtable[row].length; col++) {
                andtable[row][col] = (table1[row][col] && table2[row][col]);
            }
        }

        return(andtable);
    }

Name: Anonymous 2013-11-24 13:11

Name: Anonymous 2013-11-24 16:19

>>1

sorry m8, but u r using java and that is completely fucking gay. don't use java. only curryniggers and faggots doing CS degrees use that shit language

Name: Anonymous 2013-11-26 0:40

>>1
>return(andtable);

I'm going to lose my shit. Not just because your method is slow as fuck, but because of that mangled return statement.

Let me guess: you're an AP CS pleb who just discovered programming?

Don't change these.
Name: Email:
Entire Thread Thread List