-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathHello.java
More file actions
78 lines (58 loc) · 1.63 KB
/
Hello.java
File metadata and controls
78 lines (58 loc) · 1.63 KB
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
import java.util.ArrayList;
import java.util.List;
import java.io.*; //InputStream, InputStreamReader, BufferedReader
import math.Counter;
public class Hello {
public int count = 0;
public static void main(String[] args) {
System.out.println("Hello World!");
System.out.println(Integer.toBinaryString(8));
List<String> l1 = new ArrayList();
l1.add("A");
l1.add("B");
l1.add("C");
List<String> l2 = new ArrayList(l1);
for (String s : l2) {
System.out.println(s);
}
int i = 4;
String iStr = String.valueOf(i);
System.out.println(iStr instanceof String);
Integer iInt = Integer.parseInt(iStr);
System.out.println(iInt instanceof Integer);
Double j = 4.5;
String dStr = Double.toString(i);
System.out.println(dStr instanceof String);
Double doub = Double.parseDouble(dStr);
System.out.println(doub instanceof Double);
String f = "README.md";
readFile(f);
System.out.println("=====================");
String s = "A";
changeStr(s);
System.out.println(s.equals("A"));
Counter c = new Counter();
increment(c);
System.out.println(c.count);
}
public static void changeStr(String s) {
s = "e";
}
public static void increment(Counter c) {
c.count = 3;
}
public static void readFile(String filename) {
try {
InputStream input = new FileInputStream(filename);
InputStreamReader reader = new InputStreamReader(input);
BufferedReader buffer = new BufferedReader(reader);
String line = buffer.readLine();
while (line != null) {
System.out.println(line);
line = buffer.readLine();
}
} catch (IOException e) {
//do nothing
}
}
}