Skip to content

Commit

Permalink
Day 1 break 1
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHGR committed May 8, 2023
1 parent 2e13f36 commit 37ca046
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
Binary file added Capture 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions Questions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Q) Which are legal:

A) class X {
var x = 99;
}

B) void doStuff(var x) { }

C) void doStuff() {
var x;
x = 100;
}

D) void doStuff() {
var x = 100;
}

E) void doStuff() {
var x = null;
}

Q) Which are legal:

A) for (var x = 0; x < 3; x++)
System.out.println(x);

B) try (var in = new FileReader("");
var out = new FileWriter("")) {
}

C) try (FileReader in = new FileReader("")) {
} catch (var ex) { }

D) void doStuff() {
var x = new int[]{ 1, 2, 3 };
}

E) void doStuff() {
var x = { 1, 2, 3 };
}
48 changes: 48 additions & 0 deletions src/main/java/usingvar/Ex1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package usingvar;

//class X {
// var x = 99;
//}

import java.io.FileReader;
import java.io.FileWriter;

public class Ex1 {
// void doStuff(var x) { }
// void doStuff() {
// var x;
// x = 100;
// }
// void doStuff() {
// var x = 100;
// }
// void doStuff() {
// var x = null;
// }

public static void main(String[] args) throws Throwable {
// for (var x = 0; x < 3; x++)
// System.out.println(x);

// try (var in = new FileReader("");
// var out = new FileWriter("")) {
// }

// try (FileReader in = new FileReader("")) {
// } catch (var ex) { }

}

// void doStuff() {
// var x = new int[]{ 1, 2, 3 };
// }

// void doStuff() {
// var x = { 1, 2, 3 };
// }

// void showStuff(CharSequence [] csa) {}
// void useIt() {
// showStuff(new String[]{"a", "b"});
// }
}

0 comments on commit 37ca046

Please sign in to comment.