Results 1 to 3 of 3

Thread: Truth table

  1. #1
    ouribeb930 is offline Member
    Join Date
    Feb 2014
    Posts
    1
    Rep Power
    0

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

    }

    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default 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.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    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: 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
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Truth Table Homework Problem
    By HardToHandle in forum New To Java
    Replies: 0
    Last Post: 02-13-2012, 05:46 AM
  2. Replies: 1
    Last Post: 09-27-2011, 06:06 AM
  3. Decision structure truth table
    By JMaste in forum New To Java
    Replies: 2
    Last Post: 07-14-2010, 07:31 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
  •