File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using switch case?

 
maggie karve
Ranch Hand
Posts: 187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

compile time error???
answer is
constant expressions needed???x and y are not constants...
what does this mean??
 
saima kanwal
Ranch Hand
Posts: 148
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :

 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
maggie karve
Ranch Hand
Posts: 187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.!
 
Alpesh Rathod
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
maggie karve
Ranch Hand
Posts: 187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
question is from Examlab most probably.....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic