Code: Select all
public static void main(String args[])
	{
		final byte b=10;
		char ch='c';
		byte cb='b';
		
		switch(ch)
		{
		case'a':System.out.println("a");break;
		case b:System.out.println("b");break;
		}
	}It was compiling for the gparLondon and is also compiling for me.In your first code, case b:System.out.println("b");break; should not compile.
Could you give more details on why shouldn't it and help me figure out why I observe different behaviour?
2) another code from above:
Code: Select all
public class OverLoadingSample {
    public static void main(String args[])
    {
        call(10);
    }
    /*static void call(int i)
    {
        System.out.println("Int primitive");
    }*/
    static void call(short s)
    {
        System.out.println("short primitive");
    }
    static void call(byte b)
    {
        System.out.println("byte primitive");
    }
}3) I also tried the code from the question:
Code: Select all
        char ch = 'x';
        switch (ch) {
            case -1: System.out.println(-1); break;
            default: System.out.println("default");
        }