A Java Syntax Quirk

Posted in Java by Dan on August 24th, 2008

This little trick is shamelessly stolen from Daniele Futtorovic’s post on comp.lang.java.programmer.

This is legal, compilable Java:

public class Oddity
    public static void main(String[] args)
        System.out.println("Why is the URL allowed above?");

Why doesn’t the URL being in there upset the compiler? ┬áIf you’re not sure why it’s valid, click “show” for a spoiler.