Buscar

AULA 04 Operadores e expressões.ppt

Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original

■
■
■ 
	int x = 15; int y = x % 4;
System.out.print("Resto: ");
System.out.print(y);
■
■ 
■ 
	
	
	
	
	
	
	
	x = x + 5
	x += 5
	x = x – 5
	x -= 5
	x = x * 5
	x *= 5
	x = x / 5
	x /= 5
	x = x % 5
	x %= 5
■
	
	
	
	
	
	
	
	
	
	
■ 
■ 
■
■ 
	
	int x = 8; if (x < 9){
//Faz Algo
}
	
	boolean b = 8 > 3;
■
	
	
	
	
	
	
■ 
‘a’ == ‘a’
‘a’ == ‘b’■
5 != 6
(true == false)
boolean cincoEhDiferenteDeQuatro = 5 != 4;
■ ■
■
String
 a = “String”;
int 
b = 3;
int 
c = 7;
System.out.println(a + (b + c));
int 
d = 2; 
System.out.println(“” + d + 3);
■ 
int teste = 0;
System.out.println("Resultado: +teste++);
System.out.println(teste);
System.out.println(++teste);
System.out.println(teste--);
■
	int a = 5; int x = a++;	// e se fosse: (a++)?
int b = 20; int y = b+=3 - 2; // e se fosse: (b+=3) - 2?
int c = 10; int z = c++ + ++c; // e se fosse: (c++) + ++c?
■ ■
■ ■
■
■
//Qual será o valor de y após a execução desta linha?
int y = (2 > 3) ? 4 : 5
■ 
int y = (x < 1) ? x*x : 2-x;
■ ■
int num = 5; String msg = num > 5 ? “É maior que 5” : num > 0 ? “É maior que zero e menor que 5” : ”É um número negativo”;
■ 
boolean a = true; boolean b = !a; boolean c = !true; boolean d = !(10 > 5);■
	
	
	
	
■ 
■ 
boolean b = (2 < 3) && (3 < 4);
■
■ 
int z = 5; if (++z > 5 || ++z > 6)
z++;■
■ 
■
int
 a = 3;
int
 b = 1;
int
 c = b + 1;
int
 d = c > ++b ? (a - 3) : b;
int
 e = 4;
if( d > a && b + 1 < a || b > 1)
c += 7;
if( -7 >= -c)
a -= 4;
else
d *= 2;
e = ++d % 3;
b = d++ % 3;
■
■ 
■ 
■

Teste o Premium para desbloquear

Aproveite todos os benefícios por 3 dias sem pagar! 😉
Já tem cadastro?

Continue navegando