The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2001

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:

having problem in using run time constant in switch cases

Posted by shikha gupta on January 17, 2002 at 8:15 AM

if using the solution u give,
in one class i declare public static final constant and use this in the other class by calling it using class name.constant name,
will such a situaltion give me problem if i have to serialize my first class.
does use of static in a class which has to be serialized create any problem???
ie wil static variables/constants also be serialized???

awaiting ur reply,

regards,
shikha gupta
> change the following
> switch(event.getType()){
> case event.REPLACED;
> break;
> }

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

> In fact all labels for case statements must be a compile time constant. If you write event.REPLACED then it is not the compile time constant. You need to use classname.REPLACED i.e StatusEvent.REPLACED.

> Thanx
> Kishori






Replies:

Sponsored Links



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