Lernen am Sonntag
This commit is contained in:
35
src/org/eidecker/oca8lernen/lastminute/ArrayThings.java
Normal file
35
src/org/eidecker/oca8lernen/lastminute/ArrayThings.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package org.eidecker.oca8lernen.lastminute;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ArrayThings {
|
||||
|
||||
@Test
|
||||
public void funWithArrays() {
|
||||
int [][] a = {{1,2}, {1}};
|
||||
System.out.println("Hallo");
|
||||
|
||||
String [] strings;
|
||||
|
||||
long [][] b = {{1,2}, {1}};
|
||||
|
||||
int[] ints;
|
||||
long [] longs;
|
||||
|
||||
/* longs = (long[])ints;
|
||||
|
||||
a = (int[][])b;
|
||||
|
||||
if (a instanceof long[][])
|
||||
|
||||
if (strings instanceof String[])*/
|
||||
}
|
||||
|
||||
@Test
|
||||
public void someMoreFun() {
|
||||
short[][][][] b2 = new short[2][3][2][2];
|
||||
b2[1][1] = new short[4][4];
|
||||
System.out.println(b2);
|
||||
}
|
||||
|
||||
}
|
||||
29
src/org/eidecker/oca8lernen/lastminute/Aufgabe10.java
Normal file
29
src/org/eidecker/oca8lernen/lastminute/Aufgabe10.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package org.eidecker.oca8lernen.lastminute;
|
||||
|
||||
public class Aufgabe10 {
|
||||
}
|
||||
|
||||
class Ping extends Utils {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Utils u = new Ping();
|
||||
System.out.println(u.getInt(args[0]));
|
||||
}
|
||||
|
||||
int getInt(String a) {
|
||||
//return super.getInt(a);
|
||||
return Integer.parseInt(a);
|
||||
}
|
||||
}
|
||||
|
||||
class Utils {
|
||||
int getInt(String x) throws Exception {
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
interface Integer {
|
||||
static int parseInt(String s) throws Exception {
|
||||
return 4;
|
||||
}
|
||||
}*/
|
||||
@@ -4,6 +4,7 @@ import org.eidecker.oca8lernen.lastminute.hilfspackage.KlasseInEinemAnderenPacka
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
@@ -44,6 +45,56 @@ public class Kleinigkeiten {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wrapperSindImmutable() {
|
||||
Integer I1 = 42;
|
||||
Integer I2 = I1;
|
||||
System.out.println(I1 == I2);
|
||||
I1 += 1;
|
||||
System.out.println(I1 == I2);
|
||||
|
||||
|
||||
System.out.println(I1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void laengen() {
|
||||
int[] a = {};
|
||||
int i = a.length;
|
||||
|
||||
"Hallo".length();
|
||||
new StringBuilder("Hallo").length();
|
||||
|
||||
new ArrayList<>().size();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incrementInFor() {
|
||||
|
||||
int j = 0;
|
||||
for (j = 0; j < 6; System.out.println("Anweisung in Schleife" + j++)) {
|
||||
System.out.println(j);
|
||||
if (j == 3) break;
|
||||
}
|
||||
System.out.println("Ende: " + j);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void schleifenvariablenSichtbarkeit() {
|
||||
int[] ints = {1,2,3,4,5,6};
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int i2 : ints) {
|
||||
System.out.println(i + ": " + i2);
|
||||
for (;i2<2;) {
|
||||
System.out.println("Ganz innen " + i2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user