The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

switch statement

Posted by Jianbo on January 10, 2001 at 12:25 PM

I have a problem with "switch statement" in the following code:

final int commandId = reteriveId(); //which returns a final int
switch (commandId)
{
case ManagerCommand.SOME_NOTIFICATION:
//code block
break;
}

ManagerCommand is a "final class" and SOME_NOTIFICATION is defined in this class as "public static final int"

The compiler gives me this error message:
"constant expression required"

I don't know what is wrong with my code. Please help me. Thanks!!!



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us