Static Null

This commit is contained in:
2019-10-26 13:09:23 +02:00
parent 62d99afeb4
commit a4264d38ac
3 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
package org.eidecker.oca8lernen.general;
import org.w3c.dom.ls.LSOutput;
public class Calcs {
int root;
Calcs(int root) {
this.root = root++;
}
public static void main(String[] args) {
Calcs c = new Calcs(42);
System.out.println(++c.root);
}
}

View File

@@ -0,0 +1,25 @@
package org.eidecker.oca8lernen.general;
class StaticNull {
private static String hello = "Hello Static";
public static final void main(String [] args) {
System.out.println("Hello");
StaticNull nullReference = getNull();
System.out.println(nullReference.hello);
}
private static StaticNull getNull() {
Long l = 828282L;
double d = 2.1;
float f = 2.1f;
float f2 = 0b11;
Long l2 = 0b111L;
return null;
}
}

View File

@@ -0,0 +1,28 @@
package org.eidecker.oca8lernen.general;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class StringEquals {
@Test
public void testStringEquals() {
String s1 = "Hallo";
String s2 = "Hallo";
assertTrue(s1 == s2);
String s3 = new String("Hallo");
String s4 = new String("Hallo");
assertFalse(s3 == s4);
assertFalse(s1 == s3);
}
}