From ggc
|
01 /**
02 * All about my application here.
03 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
04 */
05 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
06 {open braces start code blocks and must be matched with a close brace
07 /**determine ifif executes the next statement only if the condition in parenthesis evaluates to true a number is big or not. A number
08 * is considered big is it is more than 50, otherwise
09 * it is considered small. Return truetrue is the boolean value that is the opposite of false from thisthis means the current object (the implicit parameter)
10 * method ifif executes the next statement only if the condition in parenthesis evaluates to true the number is considered big, falsefalse is a value for the boolean type and means not true
11 * ifif executes the next statement only if the condition in parenthesis evaluates to true it is not considered big.*/
12 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) booleanboolean is a type that is either true or false isBig(doubledouble is the type for numbers that can contain decimal fractions number)
13 {open braces start code blocks and must be matched with a close brace
14 ifif executes the next statement only if the condition in parenthesis evaluates to true(number>=this evaluates to true if the left side is not less than the right side50)
15 returnreturn means to provide the result of the method and/or cease execution of the method immediately truetrue is the boolean value that is the opposite of false;
16 elseelse is what happens when the if condition is false
17 returnreturn means to provide the result of the method and/or cease execution of the method immediately falsefalse is a value for the boolean type and means not true;
18 }close braces end code blocks and must match an earlier open brace
19
20 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) booleanboolean is a type that is either true or false isSameAndBig(intint is the type for whole numbers and it is short for integer x, intint is the type for whole numbers and it is short for integer y)
21 {open braces start code blocks and must be matched with a close brace
22 ifif executes the next statement only if the condition in parenthesis evaluates to true(x>50 &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 &&) y>50 &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 &&) x==this is the comparison operator which evaluates to true if both sides are the samey)
23 returnreturn means to provide the result of the method and/or cease execution of the method immediately truetrue is the boolean value that is the opposite of false;
24 elseelse is what happens when the if condition is false
25 returnreturn means to provide the result of the method and/or cease execution of the method immediately falsefalse is a value for the boolean type and means not true;
26 }close braces end code blocks and must match an earlier open brace
27
28 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) booleanboolean is a type that is either true or false isValidGrade(intint is the type for whole numbers and it is short for integer grade)
29 {open braces start code blocks and must be matched with a close brace
30 ifif executes the next statement only if the condition in parenthesis evaluates to true(0>grade &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 &&) grade>100)
31 returnreturn means to provide the result of the method and/or cease execution of the method immediately falsefalse is a value for the boolean type and means not true;
32 elseelse is what happens when the if condition is false
33 returnreturn means to provide the result of the method and/or cease execution of the method immediately truetrue is the boolean value that is the opposite of false;
34 }close braces end code blocks and must match an earlier open brace
35
36 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)
37 {open braces start code blocks and must be matched with a close brace
38 ifif executes the next statement only if the condition in parenthesis evaluates to true(isValidGrade(7)==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)
39 System.out.println("Passed isValidGrade(7)");
40 elseelse is what happens when the if condition is false
41 System.out.println("Failed isValidGrade(7)");
42 ifif executes the next statement only if the condition in parenthesis evaluates to true(isValidGrade(-7)==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)
43 System.out.println("Passed isValidGrade(-7)");
44 elseelse is what happens when the if condition is false
45 System.out.println("Failed isValidGrade(-7)");
46 ifif executes the next statement only if the condition in parenthesis evaluates to true(isValidGrade(700)==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)
47 System.out.println("Passed isValidGrade(700)");
48 elseelse is what happens when the if condition is false
49 System.out.println("Failed isValidGrade(700)");
50 ifif executes the next statement only if the condition in parenthesis evaluates to true(isValidGrade(0)==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)
51 System.out.println("Passed isValidGrade(0)");
52 elseelse is what happens when the if condition is false
53 System.out.println("Failed isValidGrade(0)");
54 }close braces end code blocks and must match an earlier open brace
55 }close braces end code blocks and must match an earlier open brace
|
Download/View BooleanExamples.java