Skip to content

JEFF-Media-GbR/WeirdJava

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Receiver Parameter

Receiver parameters are called "this". And you can call the method from your instance without passing anything.

public class Thing {
	// Receiver parameter
	public void doNothing(Thing this) {
		
	}
	
	public static void main(String[] args) {
        	Thing thing = new Thing();
        	thing.doNothing();
        }
}

Unicode

Unicode gets replaced before compilation.

public class Test {
	public static void main(String[] args) {
		if (true == false) { // \u000a\u007d\u007b
			System.out.println("Java can be weird. This line DOES get printed!");
		}
	}
}

Variable names

Variable names can be almost any Unicode string

class Test {
	private int __; // Works
	private int äöüß; // Works
	
	private int _; // Works only in Java 8 and older
}

Parenthesis

You can use as many as you want

class Test {
	public static void main(String[] args) {
		System.out.println("First line");
		{{{{{{{{{{{{{{{{{{{{{
			System.out.println("Second line");
		}}}}}}}}}}}}}}}}}}}}}
	}
}

"--> operator"

This isn't actually a new operator, it's just "--" and ">" combined

class Test {
	public static void main(String[] args) {
		int countdown = 10;

		// Counting down to 0
		while(countdown --> 0) {
			System.out.println(countdown);
		}

		// ... and back up
		while(countdown ++< 10) {
			System.out.println(countdown);
		}
	}
}

Random Links

Randomly inserting links into your code is no problem. This still compiles fine:

class Test {
	public static void main(String[] args) {
		https://blog.jeff-media.com
		System.out.println("Visit my website");
	}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published