From ggc
|
01 packagepackage is used to name the directory or folder a class is in intro;
02
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04
05 /**
06 * All about my application.
07 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
08 */
09 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects BooleanExamples
10 {open braces start code blocks and must be matched with a close brace
11 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
12 {open braces start code blocks and must be matched with a close brace
13 intint is the type for whole numbers and it is short for integer hoursSlept;
14 hoursSlept=this assignment operator makes the left side equal to the right side7;
15
16
17 //declaring a boolean variable
18 booleanboolean is a type that is either true or false sleepy;
19 //initialize a boolean variable;
20 sleepy=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true;
21 //boolean operators
22 sleepy=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) truetrue is the boolean value that is the opposite of false;
23 Wiki.out.println("sleepy is (false && true) is "+adds two numbers together or concatenates Strings togethersleepy);
24
25 sleepy=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) truetrue is the boolean value that is the opposite of false;
26 Wiki.out.println("sleepy is (true && true) is "+adds two numbers together or concatenates Strings togethersleepy);
27
28 sleepy=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true ||this is boolean or, meaning if either or both are true then the result is true truetrue is the boolean value that is the opposite of false;
29 Wiki.out.println("sleepy is (false || true) is "+adds two numbers together or concatenates Strings togethersleepy);
30
31 sleepy=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false ||this is boolean or, meaning if either or both are true then the result is true truetrue is the boolean value that is the opposite of false;
32 Wiki.out.println("sleepy is (true || true) is "+adds two numbers together or concatenates Strings togethersleepy);
33
34 sleepy=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true ||this is boolean or, meaning if either or both are true then the result is true falsefalse is a value for the boolean type and means not true;
35 Wiki.out.println("sleepy is (false || false) is "+adds two numbers together or concatenates Strings togethersleepy);
36
37 sleepy =this assignment operator makes the left side equal to the right side hoursSlept <=this evaluates to true if the left side is not more than the right side 7;
38 Wiki.out.println("sleepy is (" +adds two numbers together or concatenates Strings together hoursSlept +adds two numbers together or concatenates Strings together "<=7) is " +adds two numbers together or concatenates Strings together sleepy);
39
40 sleepy =this assignment operator makes the left side equal to the right side hoursSlept <=this evaluates to true if the left side is not more than the right side 10;
41 String message =this assignment operator makes the left side equal to the right side "sleepy is (" +adds two numbers together or concatenates Strings together hoursSlept +adds two numbers together or concatenates Strings together "<=10) is " +adds two numbers together or concatenates Strings together sleepy;
42 Wiki.out.println(message);
43
44 booleanboolean is a type that is either true or false baby=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true;
45
46 sleepy =this assignment operator makes the left side equal to the right side (baby==this is the comparison operator which evaluates to true if both sides are the sametruetrue is the boolean value that is the opposite of false &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) hoursSlept<10) ||this is boolean or, meaning if either or both are true then the result is true (baby==this is the comparison operator which evaluates to true if both sides are the samefalsefalse is a value for the boolean type and means not true &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) hoursSlept<7);
47 message =this assignment operator makes the left side equal to the right side "sleepy is ("+adds two numbers together or concatenates Strings togetherbaby+adds two numbers together or concatenates Strings together"==true && "+adds two numbers together or concatenates Strings togetherhoursSlept+adds two numbers together or concatenates Strings together"<10) || ("+adds two numbers together or concatenates Strings together
48 baby+adds two numbers together or concatenates Strings together"==false && "+adds two numbers together or concatenates Strings togetherhoursSlept+adds two numbers together or concatenates Strings together"<7) is "+adds two numbers together or concatenates Strings together sleepy;
49 Wiki.out.println(message);
50 }close braces end code blocks and must match an earlier open brace
51 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/BooleanExamples.java