Shorthands for Reassignment
All the same shorthands for reassignment work with double
s the same as they do with int
s.
double x = 0.5;
// 0.5
System.out.println(x);
x += 3;
// 3.5
System.out.println(x);
x -= 1;
// 2.5
System.out.println(x);
x++;
// 3.5
System.out.println(x);
x--;
// 2.5
System.out.println(x);
x *= 5;
// 12.5
System.out.println(x);
x /= 2;
// 6.25
System.out.println(x);