-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
72 lines (53 loc) · 2.14 KB
/
Copy pathMain.java
File metadata and controls
72 lines (53 loc) · 2.14 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
import java.util.Arrays;
import java.util.Random;
public class Main {
public static void main(String[] args) {
int[] numbers = {3, 5, 6};
numbers = new int[4];
numbers[0] = 2;
numbers[1] = 2;
System.out.println(Arrays.toString(numbers));
int x = 4;
short xx = (short) x;
Integer a = Integer.valueOf(1237);
Integer b = Integer.valueOf(1237);
System.out.println(a.equals(b));
String hello = "hello";
String seyHello = new String("hello");
seyHello = seyHello.intern();
System.out.println(hello == seyHello);
Student bob = new Student();
bob.setAge(19);
bob.setName("Bob");
bob.setFavoriteSubject("Math");
bob.getPersonalInfo();
Employee alice = new Employee(3.4,45);
alice.setAge(20);
alice.setName("Alice");
alice.getPersonalInfo();
Person person = new Person();
person.setAge(34);
person.setName("Jhon");
person.getPersonalInfo();
System.out.println(">>>>>>toString overriding>>>>>>>>");
System.out.println("а якщо без методів напряму з обєкта то треба перевизначити метод toString(): " + "\n" + alice);
System.out.println("через гетер виводим інфо: " + alice.getAge());
System.out.println(">>>>>>toString overriding>>>>>>>>");
int age = 18;
String massage = age >= 18 ? "you can buy alcohol" : "you can not buy";
System.out.println(massage);
Season season = Season.SPRING;
System.out.println(season);
Season[] seasons = Season.values();
System.out.println(Arrays.toString(seasons));
Random random = new Random();
int randomValue = random.nextInt(44);
System.out.println(randomValue);
DayOfWeekSupplier day = new DayOfWeekSupplier();
for (int i = 0; i < Season.values().length; i++) {
System.out.println(day.getRandomDayOfWeek());
}
System.out.println("main contin34");
System.out.println("another massage");
}
}