Философия Java


Руководство по операторам - часть 2


//! boolean b = (boolean)x;

byte B = (byte)x; short s = (short)x; int i = (int)x; long l = (long)x; float f = (float)x; double d = (double)x; } void byteTest(byte x, byte y) { // Арифметические операторы:

x = (byte)(x* y); x = (byte)(x / y); x = (byte)(x % y); x = (byte)(x + y); x = (byte)(x - y); x++; x--; x = (byte)+ y; x = (byte)- y; // Сравнение и логика:

f(x > y); f(x >= y); f(x < y); f(x <= y); f(x == y); f(x != y); //! f(!x);

//! f(x && y);

//! f(x || y);

// Битовые операторы:

x = (byte)~y; x = (byte)(x & y); x = (byte)(x | y); x = (byte)(x ^ y); x = (byte)(x << 1); x = (byte)(x >> 1); x = (byte)(x >>> 1); // Совмещение присваения:

x += y; x -= y; x *= y; x /= y; x %= y; x <<= 1; x >>= 1; x >>>= 1; x &= y; x ^= y; x |= y; // Приведение:

//! boolean b = (boolean)x;

char c = (char)x; short s = (short)x; int i = (int)x; long l = (long)x; float f = (float)x; double d = (double)x; } void shortTest(short x, short y) { // Арифметические операторы:

x = (short)(x * y); x = (short)(x / y); x = (short)(x % y); x = (short)(x + y); x = (short)(x - y); x++; x--; x = (short)+y; x = (short)-y; // Сравнение и логика:

f(x > y); f(x >= y); f(x < y); f(x <= y); f(x == y); f(x != y); //! f(!x);

//! f(x && y);

//! f(x || y);

// Битовые операторы:

x = (short)~y; x = (short)(x & y); x = (short)(x | y); x = (short)(x ^ y); x = (short)(x << 1); x = (short)(x >> 1); x = (short)(x >>> 1); // Совмещение присвоения:

x += y; x -= y; x *= y; x /= y; x %= y; x <<= 1; x >>= 1; x >>>= 1; x &= y; x ^= y; x |= y; // Приведение:

//! boolean b = (boolean)x;

char c = (char)x; byte B = (byte)x; int i = (int)x; long l = (long)x; float f = (float)x; double d = (double)x; } void intTest(int x, int y) { // Арифметические операторы:

x = x * y; x = x / y; x = x % y; x = x + y; x = x - y; x++; x--; x = +y; x = -y; // Сравнение и логика:

f(x > y); f(x >= y); f(x < y); f(x <= y); f(x == y); f(x != y); //! f(!x);




Начало  Назад  Вперед