Array problem.

Ok I have a problem, I'm making an ip calculator that calculates the subnet address and the NetID.

I've created 2 arrays which contain the binary code of the octet handleling the Mask and the IP field, this is working fine, so you get a bunch of 0 and 1's

To find out what the NetID is you AND the to arrays thats what my code below is supposed to do.

But its of cource not, it says 1 * 0 = 2342 which is weird, because when I System.out.println (supipa.charAt(0) i get either 0 or 1, same for maska.charAt(0).

My question is way does it do this, can't an array multiply or something.

int[] subnetidarray =newint [AANTAL_BIT];

for (int b =0; b<subnetidarray.length; b++){

subnetidarray[b] = subipa.charAt(b) * maska.charAt(b);

}

for (int n = 0; n><subnetidarray.length; n++){

buffer.append (subnetidarray[n]);

}

netid.setText(buffer.toString());

>

[1289 byte] By [MrHusa] at [2007-11-27 4:52:39]
# 1
You're multiplying the ascii values of two characters -- not the values that they represent on the screen. You can use the Integer or Character classes' parse methods to convert the characters to the integer values that they read.
ktm5124a at 2007-7-12 10:06:43 > top of Java-index,Java Essentials,Java Programming...