1. Member
Join Date
Feb 2014
Posts
1
Rep Power
0

## Truth table

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);

}

}

2. ## Re: Truth table

what are you having problems with? Can you ask some specific questions about specific statements in the program?

[code]
[/code]
to get highlighting and preserve formatting.

3. ## 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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•