Examples for Trace1.txt --------------------------------------------------- // Example 1. public class Main { public static void main(String[] args) { int x = 5, y = 3, z; z = x + 2 * y; y = 5 * (x - 1); x += 3; System.out.println(x + " " + y + " " + z); } } --------------------------------------------------- // Example 2. public class Main { public static void main(String[] args) { int x = 2, y = 3; y = x + 2 * y; x += 5; System.out.println(x + " " + y); x = 3 * x + y; System.out.println(x); x /= 2; System.out.print((x + y) % 2); x++; y++; System.out.println(" " + (x + y)); } } --------------------------------------------------- // Example 3. public class Main { public static void main(String[] args) { int x = 2, y = 3, z = 7; z += (x + 2 * y); x *= y; y = x + z - 1; x--; y--; System.out.print(x + " " + y + " " + z + " "); x = 2 * z + y; y = 2 * x + z; z = 2 * y + x; System.out.print(x + " " + y + " "); y = 3 * x - 2; z -= 5; System.out.print(z + " "); } } --------------------------------------------------- // Example 4. public class Main { public static void main(String[] args) { int x = 1, y = 2; boolean f, g; f = (x == 1) && (y == 3); g = (x + y <= 0) || (x != y); System.out.println(f + " " + g); } } --------------------------------------------------- // Example 5. public class Main { public static void main(String[] args) { int x = 1, y = 2, z = 5; boolean f, g; z += (x + y); f = (x + y + z > 5) && (y * z > 15); g = (true || (5 == 5)) && (x + z > 3 * y); System.out.println(f && !g); } } --------------------------------------------------- // Example 6. public class Main { public static void main(String[] args) { int x = 2, y = 3; boolean f; x *= 2; y *= 3; f = (x > 5) || !(y > 5); System.out.print(f + " " + x + " " + y + " "); x = 3 * x + 4 * y - 2; y += (4 * x + 1); x++; y--; System.out.println(f + " " + x + " " + y + " "); } } --------------------------------------------------- // Example 7. public class Main { public static void main(String[] args) { // Long declaration and initialization of w. String x = new String("apple"); // Short declaration and initialization. String y = "peach", z = "orange"; // Declaration only. String w; w = z + "$$$" + y + "*" + x; System.out.println("Output = " + w); } } --------------------------------------------------- // Example 8. public class Main { public static void main(String[] args) { String x = "st", y = "iv", z = "qw"; x += z; y += x; System.out.print(z + x + y); x += "@"; y += "&"; z += "?"; System.out.println(y + z + x); } } ---------------------------------------------------