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:

I have a similar problem

Posted by Sachin Sawe on February 22, 2002 at 4:08 PM

Hi Natasha,

I have the same problem. can you tell me whether ur problem got solved ?


> Hi!
> I have a problem with the case lablel of the switch statement.
> I have 2 classes namely "StatusEvent" & "test". The StatusEvent
> class has a public static final int as follows:

> public class StatusEvent{
> public static final int REPLACED = 1;
> .
> .
> .
> public int getType(){
> return 1;
> }
> }

> In the test class I use the StatusEvent as follows:

> public void processEvent(StatusEvent event){

> switch(event.getType()){
> case event.REPLACED;
> break;
> }

> At compile time I get an error : constant expression required,
> even though REPLACED is a public static final int in the
> StatusEvent class. Any suggestions??

> PS this is somewhat similar to the problem posted on Jan 11.






Replies:

Sponsored Links



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