MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / AllOps

Class AllOps

operators/AllOps.java:8–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6// to show which ones are accepted by the Java compiler
7
8public class AllOps {
9 // To accept the results of a Boolean test:
10 void f(boolean b) {}
11 void boolTest(boolean x, boolean y) {
12 // Arithmetic operators:
13 //- x = x * y;
14 //- x = x / y;
15 //- x = x % y;
16 //- x = x + y;
17 //- x = x - y;
18 //- x++;
19 //- x--;
20 //- x = +y;
21 //- x = -y;
22 // Relational and logical:
23 //- f(x > y);
24 //- f(x >= y);
25 //- f(x < y);
26 //- f(x <= y);
27 f(x == y);
28 f(x != y);
29 f(!y);
30 x = x && y;
31 x = x || y;
32 // Bitwise operators:
33 //- x = ~y;
34 x = x & y;
35 x = x | y;
36 x = x ^ y;
37 //- x = x << 1;
38 //- x = x >> 1;
39 //- x = x >>> 1;
40 // Compound assignment:
41 //- x += y;
42 //- x -= y;
43 //- x *= y;
44 //- x /= y;
45 //- x %= y;
46 //- x <<= 1;
47 //- x >>= 1;
48 //- x >>>= 1;
49 x &= y;
50 x ^= y;
51 x |= y;
52 // Casting:
53 //- char c = (char)x;
54 //- byte b = (byte)x;
55 //- short s = (short)x;
56 //- int i = (int)x;
57 //- long l = (long)x;
58 //- float f = (float)x;
59 //- double d = (double)x;
60 }
61 void charTest(char x, char y) {
62 // Arithmetic operators:
63 x = (char)(x * y);
64 x = (char)(x / y);
65 x = (char)(x % y);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected