-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
40 lines (33 loc) · 1.03 KB
/
Copy pathApp.java
File metadata and controls
40 lines (33 loc) · 1.03 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
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Random;
public class App {
public static void main(String[] args) {
helloWorld(new Random(), 23, 0);
}
private static void printFourthElement(int[] a){
System.out.println(a[3]);
}
void readFirstByteFromFile(File fileName){
FileInputStream file = null;
try {
file = new FileInputStream(fileName);
byte x = (byte) file.read();
System.out.println(x);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static void helloWorld(Random rand, int value, int retry) {
int max = 1000, min = 10;
int intRan = rand.nextInt(max - min + 1) + min;
if (value == intRan) {
System.out.println("Hello world");
System.out.println("Retry: " + retry);
} else {
System.out.println("running...");
helloWorld(rand, value, retry + 1);
}
}
}