Booleans - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Booleans - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Wednesday, March 13, 2019

Booleans

Booleans


üSize is 1 bit – two value: true and false.
üThis type is returned by all relational operators.

üExample:

  boolean b;
  b= true;
System.out.println(“b is “+b);
System.out.println(“10>9 is “ +(10>9));

Output:

b is true
10>9 is true
Literals

üInteger Literals

  1. base 10 – 1,2,43 etc.
  2. base 8 – octal values are denoted in java by a leading 0.
  3. base 16 – hexadecimal values are denoted by leading 0x    or 0X.

}Any whole number is by default integer (32 bits).
}To specify a long literal, the number should appended with
  an upper- or lowercase L.

üFloating point Literals

  1. Standard Notation – 3.14159, 0.6667, 2.0 etc.
  2. Scientific Notation – 6.022E23, 2e+100.
}Floating point literals are by default of type double.
}To specify a float literal, we must append an F or f to the constant.

üBoolean Literals

}Two values – true and false.
}True is not equal 1 and false is not equal to 0.
}They can be assigned to variable declared as boolean.

üCharacter Literals:

}A literal character is represented inside a pair of single quotes.

üString Literals

}A sequence of characters between a pair of double quotes.
}In java string must begin and end on the same line.

No comments:

Post a Comment

Post Top Ad