-
Notifications
You must be signed in to change notification settings - Fork 2
/
MyFirstProgram.java
97 lines (80 loc) · 1.52 KB
/
MyFirstProgram.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import java.io.*;
import cc.*;
import java.util.Iterator;
class Test {
public void m() {
System.out.println("Test.m");
}
}
class Yo extends Test {
int a = 4;
public Yo() {
System.out.println("Yo constructor");
}
@Override public void m() {
super.m();
System.out.println("Yo.m");
}
public void v() {
int b = a;
b++;
a = b;
System.out.println(b);
m();
int[] errTest = new int[3];
int errTest2 = errTest[5];
}
}
public class MyFirstProgram {
static int a = 6;
/** Print a hello message */
public static void main(String[] args) {
int a = getNumber();
System.out.println("Hello, world!");
System.out.println(Computer.isTurtle());
System.out.println(a+a);
Yo y = new Yo();
try {
y.v();
} catch (ArrayIndexOutOfBoundsException e) {
e.printStackTrace();
}
Test t = y;
t.m();
Iterable<String> i = new Iterable<String>() {
public Iterator<String> iterator() {
return new Iterator<String>() {
String[] arr = {"Hey", "You", "Mr.", "Clue"};
int i = 0;
{
arr[0] = "Hey";
arr[1] = "You";
arr[2] = "Mr.";
arr[3] = "Clue";
}
public boolean hasNext() {
if (i < arr.length)
return true;
return false;
}
public String next() {
return arr[i++];
}
public void remove() {
}
};
}
};
for (String s : i) {
System.out.println(s);
}
System.out.println("" instanceof String);
}
public static int getNumber()
{
return a;
}
static {
System.out.println("Test static");
}
}