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

public static final

 
Jammy Wells
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have started reading Kathy Sierra Scjp 1.4 book....In the second chapter we have a question which asks indirectly whether U can compile "public static final int k;" as an instance variable declaration or not and the answer provided for this was that U can. I tried writing a class which declares a member variable in above mentioned manner,it gave me a compilation error according to which I shud have initialized this variable by assiging sme value to it.Please tell me whether its smething wrong in the Book's mentioned statement or smething else.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

"public static final int i;" is legal, but only if you initialize the variable somewhere, such as in a static initialization block. For example,

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic