-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.java
More file actions
137 lines (104 loc) · 2.41 KB
/
Copy pathloop.java
File metadata and controls
137 lines (104 loc) · 2.41 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
class loop
{
public static void main(String args[])
{
//if-else loop
int x = 5;
if(x>3)
{
System.out.println("yes");
}
if(true)
{
System.out.println("yes");
}
if(x>10)
{
System.out.println("no");
}
if(x>10 && x<20)
{
System.out.println("yes");
}
else
{
System.out.println("no");
}
int y = 9;
if(x>y)
System.out.println(x);
else
System.out.println(y);
int z = 10;
if(x>y && x>z)
{
System.out.println(x);
}
else if(y>z)
{
System.out.println(y);
}
else
{
System.out.println(z);
}
int a = 5;
String result = a%2==0 ? "even":"odd";
System.out.println(result);
//switch case
int n = 9;
switch(n)
{
case 1:
System.out.println(1);
break;
case 2:
System.out.println(2);
break;
case 3:
System.out.println(3);
break;
case 4:
System.out.println(4);
break;
case 5:
System.out.println(5);
break;
default:
System.out.println("invalid");
}
String day = "Monday";
String rez = "";
switch(day)
{
case "Saturday","Sunday" -> System.out.println("holiday");
case "Monday" -> rez = "Shit!";
default -> System.out.println("7 A.M");
}
System.out.println(rez);
// while-loop
int i = 1;
while(i<=10)
{
System.out.println("i = " + i);
int j = 1;
while (j<=3)
{
System.out.println("j = " + j);
j++;
}
i++;
}
// do-while loop
int p = 3;
do
{
System.out.println("hello");
}while(p>5);
// for-loop
for(int k = 1; k<=5; k++)
{
System.out.println("for working : " + k);
}
}
}