forked from Hesenius/SafariJava17CertStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}); | ||
// } | ||
} |