# Truth table

Printable View

• 02-12-2014, 07:35 PM
ouribeb930
Truth table
Can someone please help me explaining this code.

public class Test {
public static void main(String[] args) {

char start[] = {0,1,2,3,4};
char end[] = {0,1,2,3,4};

boolean truth;

truth = (start.length & end.length) == 6;
System.out.println("(" + start.length + "&" + end.length + ") == 6 : " + truth);

truth = (start.length & end.length) != 6;
System.out.println("(" + start.length + "&" + end.length + ") != 6 : " + truth);

truth = (start.length | end.length) == 6;
System.out.println("(" + start.length + "|" + end.length + ") == 6 : " + truth);

truth = (start.length | end.length) != 6;
System.out.println("(" + start.length + "|" + end.length + ") != 6 : " + truth);

truth = (start.length ^ end.length) == 6;
System.out.println("(" + start.length + "^" + end.length + ") == 6 : " + truth);

truth = (start.length ^ end.length) != 6;
System.out.println("(" + start.length + "^" + end.length + ") != 6 : " + truth);

}

}
• 02-12-2014, 07:56 PM
Norm
Re: Truth table
what are you having problems with? Can you ask some specific questions about specific statements in the program?

Please edit your post and wrap your code with code tags:
[code]
YOUR CODE HERE
[/code]
to get highlighting and preserve formatting.
• 02-12-2014, 09:39 PM
JosAH
Re: Truth table
Apply a bit of simple math: for every integer number n: n&n == n, n|n == n, n^n == 0

kind regards,

Jos