int x = 11;
int y = 7;
int a = x + y; // a = 18
int s = x - y; // s = 4
int m = x * y; // m = 77
int d = x / y; // d = 1
int r = x % y; // r = 4
int x = 5;
int a, b;
a = x++; // a = 5 x = 6
x--; // x = 5
b = ++x; // b = 6 x = 6
++x; // x = 7
boolean bool = true;
// true
System.out.println(bool);
// false
System.out.println(!bool);
Equality and Relational Operators
int x = 5;
int y = -5;
System.out.println(x == y); // false
System.out.println(x != y); // true
System.out.println(x >= y); // true
Conditional Operators
score >= 3 && score <= 5
day == "Saturday" || day == "Sunday"
What is the result?
int t = 5, s = 4, v = 7;
System.out.println(t > s && t > v || s < v);
System.out.println((t < v || s > v) && t < s);
Ternary (conditional operator) consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide which value should be assigned to the variable.
if (temperature<10) {
System.out.println(“It’s too cold”);
} else {
System.out.println(“It’s Ok”); ;
}
The if-then statement tells your program to execute a certain section of code only if a particular test evaluates to true.
switch
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.
Enum
Example
Comparing objects
Which will be the results?
Student student1 = new Student("Ira", 25);
Student student2 = new Student("Ira", 25);
System.out.println(student1 == student2);
System.out.println(student1.equals(student2));
Which will be the results?
Student student1 = new Student("Ira", 25);
Student student2 = new Student("Ira", 25);
System.out.println(student1 == student2);
System.out.println(student1.equals(student2));
Class Calc
Class CalcTest
Practical tasks
Homework
Если не удалось найти и скачать презентацию, Вы можете заказать его на нашем сайте. Мы постараемся найти нужный Вам материал и отправим по электронной почте. Не стесняйтесь обращаться к нам, если у вас возникли вопросы или пожелания:
Email: Нажмите что бы посмотреть