new example progs

This commit is contained in:
Christoph
2020-12-10 19:17:06 +01:00
parent 5197ca011d
commit 4683924b46
5 changed files with 75 additions and 8 deletions

View File

@ -0,0 +1,14 @@
class WhileClass {
public static void main(String[] args) {
int test = 1;
test = 2;
{
// Shadowing
int test = 1;
test = 2;
}
}
}

View File

@ -0,0 +1,23 @@
class MyClass {
public static void main(String[] args) {
// Integer
a = 1 + 2;
b = 1 + a * 2;
c = (1 + 2) * b;
d = (a - 5) / (2 - y) + 21;
e = -1;
f = 1 / -1 * -3 + (5 - -6);
// Boolean
a = true;
b = 5 < 6;
c = !(5 < 6);
d = (5 < 6) && !(6 < 5);
e = 4 <= (4 + 1);
f = "Hallo" == "Hallo";
// String
a = "Hallo";
}
}

View File

@ -11,5 +11,15 @@ class IfElseClass {
}
}
System.out.println("x und y sind gleich gross.");
if (1 < 2)
String s = "Ohne Klammern, da 1 Line.";
if (1 < 2)
s = "If 1";
if (2 < x)
s = "If 2";
else
s = "Dangling else";
}
}

View File

@ -1,14 +1,20 @@
class WhileClass {
public static void main(String[] args) {
// int a = 1;
// int b = 1;
// int temp = 0;
while (a < b) { // (a < 144)
// temp = b;
// b = a + b;
// a = temp;
// System.out.println(a);
int a = 1;
int b = 1;
int temp = 0;
while (a < 144) {
temp = b;
b = a + b;
a = temp;
System.out.println(a);
}
while (b < 1)
temp = 55;
}
}

View File

@ -0,0 +1,14 @@
class WhileClass {
public static void main(String[] args) {
int test = 1;
int test = 1;
int test = 1;
int test = 1;
int test = 1;
int test = 1;
int test = 1;
int test = 1;
}
}