| Author |
using switch case?
|
maggie joseph
Ranch Hand
Joined: Dec 29, 2009
Posts: 185
|
|
compile time error???
answer is
constant expressions needed???x and y are not constants...
what does this mean??
|
 |
saima kanwal
Ranch Hand
Joined: Oct 05, 2009
Posts: 148
|
|
the problem is with variable y: it should be a constant (that is should be marked final) and it should be a compile time constant which means that y should be declared and initialized at the same time.Refer to page 336 Chapter 5 of K & B .
so the correct code is :
|
SCJP 6.0 (86%) SCWCD 5 (94%)
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
maggie you are not following the quoting of source rule properly. You've asked a lot of questions without a proper source (like this, this, this and this). Quoting source is not optional at javaranch. If you don't quote the source properly, then we might have to delete your questions...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
maggie joseph
Ranch Hand
Joined: Dec 29, 2009
Posts: 185
|
|
|
ok..i will do that from next post..actually i am trying lots of code on my own too.so its a combination of all that..anyways i will take care from next time....
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
maggie joseph wrote:ok..i will do that from next post..
No. Tell us what the source of the above question is now. As you've been told multiple times, it's required on JavaRanch.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Abimaran Kugathasan
Ranch Hand
Joined: Nov 04, 2009
Posts: 2066
|
|
The case constant must be a compile time constant! Since the case argument has to be resolved at compile time, that means you can use only a constant or final variable that is assigned to literal value.
I think, this may help to you.!
|
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
|
 |
Alpesh Rathod
Ranch Hand
Joined: Jan 06, 2009
Posts: 41
|
|

Abimaran Kugathasan wrote:The case constant must be a compile time constant! Since the case argument has to be resolved at compile time, that means you can use only a constant or final variable that is assigned to literal value.
I think, this may help to you.!
Very good very good...
|
Thanks,
Alps
|
 |
maggie joseph
Ranch Hand
Joined: Dec 29, 2009
Posts: 185
|
|
|
question is from Examlab most probably.....
|
 |
 |
|
|
subject: using switch case?
|
|
|