ok, after i cut out all of the inside stuff heres where im getting the error



Code:
class Switchtest {
    switch(5) {
        default:
            System.out.println("p");
    } 
}


That should be valid right? Well heres the error im getting

Code:
d:\prog\java>javac switch.java
switch.java:4: illegal start of type
    switch(5) {
    ^
switch.java:7: <identifier> expected
    }
     ^
2 errors

d:\prog\java>
The second error is due to the first one, since its not recongizing switch, though WHY? When i add in the main method it compiles just fine.


Code:
class Switchtest {
    public static void main(String[] args) {
        switch(5) {
            default:
                System.out.println("p");
        } 
    }   
}

I should be using the 1.4.2 Java SDK