assertion question


class Language{
    public static final int java=1;
    public static final int pascal=2;
    public static final int csharp=3;

}
public class Mgos  {
    static int lang=0;
    public static void main(String argv[]){
        switch(lang){
        case Language.java:
            System.out.println("java");
            break;
        case Language.pascal:
            System.out.println("pascal");
            break;
        case Language.csharp:
            System.out.println("csharp");
            break;
        default:
            assert false : lang;
        }

    }

}

I was trying above example from link

http://www.jchq.net/certkey/0205certkey.htm

did not understand output while running in eclipse ide.

I was trying to understand the output. Wow can i pribt say java to the console.


 Any links, ideas, resources,sample code highly appreciated. thanks in advance.
LVL 7
gudii9Asked:
Who is Participating?
 
CEHJCommented:
That won't do anything unless  you run it with assertions enabled, in which case it will print 0
0
 
objectsCommented:
It will not output anything
the value of lang is 0 which does not match any of the switch cases so the default gets executed.
the assert is ignored as assertions are not enabled

0
 
gudii9Author Commented:
>>>That won't do anything unless  you run it with assertions enabled, in which case it will print 0

I am getting message on console like

>>Exception in thread "main" java.lang.AssertionError: 0
      at com.vaannila.student.Mgos.main(Mgos.java:23)

after enabling assertion in eclipse ide and ran as java application.

Are you referring to same '0'.

How can i get something like java or pascal. please advise
0
 
objectsCommented:
>     static int lang=0;


change that to:


    static int lang=1;
0
 
gudii9Author Commented:
sure. i will try
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.