Post

Operador, Conversiones

✅ Operador

1
2
3
4
5
6
7
8
9
10
int i=1;
int z;

z = 5 + i++; //z=6
z = 5 + i;
i++;

z= 5 + ++i; //7
i++;
z = 5 + i;

✅ Conversiones, Casting

  1. Conversiones implicitas
1
2
3
4
5
int x = 5;
double y;

y = x;
//possible, double > int
1
2
3
4
5
int x ;
double y = 5.3;

x = y;
//not possible, double > int
  1. Conversiones explicitas = casting
1
2
3
4
5
6
int x ;
double y = 5.3;

x = (int) y;
//now possible
// x = 5 , trunca

This post is licensed under CC BY 4.0 by the author.