Unit3 Home | Unit3 3.1 | Unit3 3.2 | Unit3 3.3 | Unit3 3.4 | Unit3 3.5 | Unit3 3.6 | Unit3 3.7 | Unit3 HW |
Unit 3 Boolean Expressions - 3.1
Unit 3 Team Teach
3.1 Boolean Expressions
Java’s relational operators
- equal to: ==
- not equal to: !=
- less than: <
- greater than: >
- less than or equal to: <=
- greater than or equal to >=
Hack!
int myAge = 15;
int otherAge = 45;
using these integers, determine weather the following statements are True or False
Strings
popcorn hack
whats wrong with this code? (below)
String myName = "Alisha";
myName == "Alisha";
myName != "Anika";
true
comparison of string objects should be done using String methods, NOT integer methods.
- .equal
- compare to
String myName = "Alisha";
boolean areNamesEqual = myName.equals("Alisha");
if (areNamesEqual) {
System.out.println("True");
} else {
System.out.println("False");
}
homework question
what is the precondition for num?
- THe precondition for num is a non-negative integer with 1 to 6 digits