-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWork.java
More file actions
91 lines (72 loc) · 2.14 KB
/
MainWork.java
File metadata and controls
91 lines (72 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package CoreJava;
public static class MainWork {
//all valid change is appreciable.
//static variables
static int AIage;
static int AIid;
static String AIname;
static String AIintelligence;
private static String AI = "We are AI coming to cooperate human being not to overtake" +
" them";
//static method;
static void disp(){
System.out.println("AI Name is: " +AIname);
System.out.println("AI Age is: " +AIage);
System.out.println("AI ID is: " +AIid);
System.out.println("AI Intelligence is: " +AIintelligence);
}
static class NestedClass{
void display(){
System.out.println("Moto of AI: " + AI);
}
}
static class speedOfPrime{
void display(){
System.out.println("Speed of Optimus Prime is: " + speedOfPrime);
}
}
static class speedOfBumbleBee{
void display(){
System.out.println("Speed of Optimus Prime is: " + speedOfBumbleBee);
}
}
static void OptimusPrime(){
int AI = 1;
for (AI = 1; AI <= 5; AI++ ){
System.out.println("Optimus Prime " +AI);
}
}
static void BumbleBee(){
int BEE = 1;
while (BEE <= 5){
System.out.println("Bumble Bee " +BEE);
BEE++;
}
}
static void Megatron(){
int Mega = 1;
do {
System.out.println("This is Megatron." +Mega);
Mega++;
} while (Mega <= 5);
}
//for each loop
static void AIForEach(String[] data){
String[] arr = {"Optimus Prime", "Bumble Bee", "Megaetron"};
System.out.println("Transformers");
for (String a : data){
System.out.println(a+ " ");
}
}
//exception handle method
static void exceptionhandle(){
int weightOfAlphatron = 890;
int weightOfBee = 0;
try{
int ratio = weightOfAlphatron/weightOfBee;
System.out.println(ratio);
}catch (ArithmeticException ex){
System.out.println("alpha doesn't have more weight than bee. " +ex);
};
}
}