Created
January 8, 2020 04:15
-
-
Save oO0oO0oO0o0o00/30d43a90dac3975998e768a53ca57dd5 to your computer and use it in GitHub Desktop.
This sucks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class HelloWorld { | |
public static void main(String[] args) { | |
byte abyte = (byte) 3; | |
if (Math.random() < 1) abyte++;// No static opt | |
Object a = abyte; | |
Object b = (Object) (byte) 4; | |
Object c = (Object) 4; | |
System.out.println(a == b);// T | |
System.out.println(a.equals(b));// T | |
System.out.println(c == b);// F, types matter | |
System.out.println(c.equals(b));// F | |
String dString = "fuck"; | |
if (Math.random() < 1) dString += "you"; | |
Object d = dString; | |
Object e = "fuckyou"; | |
System.out.println(d == e);// F, by ref | |
System.out.println(d.equals(e));// T, by val | |
Object f = new int[]{1, 2}; | |
int[] gA = new int[]{2, 2}; | |
if (Math.random() < 1) gA[0] = 1; | |
Object g = gA; | |
System.out.println(f == g);// F, by ref | |
System.out.println(f.equals(g));// F, not overrided | |
System.out.println(Arrays.equals((int[]) f, (int[]) g));// T, must cast as its non-virtual | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment