File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes  :( one more stupid misstake, pls help me ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " :( one more stupid misstake, pls help me !" Watch " :( one more stupid misstake, pls help me !" New topic
Author

:( one more stupid misstake, pls help me !

Hiep Nguyen
Ranch Hand

Joined: Oct 26, 2001
Posts: 46
this is my real code:

if i open one of two comments or open two comments, when compile, it has these error
[error]
gui/Stupid.java [21:1] duplicate case label
case Define.CMD_DETAIL_GROUP:
^
gui/Stupid.java [34:1] duplicate case label
case Define.CMD_DETAIL_GROUP:
^
2 errors
Errors compiling Stupid.
[/errors]
i already check, but i don't why it has the error. do you have the error? my code stupid or my JVM is stupid?
thanks !
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Any field defined in an interface must be static and final. Since CMD_ADD_GROUP and CMD_DETAIL are declared in the 'Define' interface, they are therfore implicity static and final (even though you didn't have to write out the keywords).
Java compilers inline static final constants. As an illustration:

Here's a slightly off-topic digression that you may read or ignore as you like:
Constant inlining is actually something to be careful of when you're writing libraries for other developers to use from their code. Suppose you distributed fancyLogger-1.0.jar with this declaration:

I compiled against that version. Then you write a new version, fancyLogger-2.0.jar:

If I drop fancyLogger-2.0.jar next to my code (compiled agains fancyLogger-1.0.jar), the logging will be messed up. My compiled code treats WARN as 0 and ERROR as 1 -- the only way to change that is to recompile. When I try to run the incompatable versions, where I wanted ERROR I'll get WARN. Where I wanted WARN, I'll probably get an error claiming there is no such constant as 0.
That was a long-winded way of explaining something that isn't too complex.
Back on topic:
The is probably a mistake, but CMD_ADD_GROUP and CMD_DETAIL are both assigned the value 10.

Is treated by the compiler as

You probably wanted CMD_DETAIL_GROUP to equal 13, not 10.
[ February 19, 2003: Message edited by: David Weitzman ]
Hiep Nguyen
Ranch Hand

Joined: Oct 26, 2001
Posts: 46
oh! i'm really stupid , because my code so long so i have a misstake, and i also don't careful when post the short code.
thank you so much!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: :( one more stupid misstake, pls help me !
 
Similar Threads
Switch Case question
switch doubt..
the "break" statement
Do while error, I'm going crazy
How close am I in getting this program right?