File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

preferences in JDK1.4 Tutorial

 
alex earnshaw
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I've been looking at this book by Greg Travis in preparation for the SCJP 1.4 (whenever it comes online)
In the Preferences chapter (section 10.4.2 page 311) there is a code fragment:

I have tried compiling this fragment by putting it in the constructor of a test class (PrefsTest), and got the error:

Does anyone know anything about the new preferences API. From the error it seems you cannot use 'this' as an argument...can anyone explain?
Thanks
Alex
 
Bonnie Beach-Morin
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the looks of the API, that method requires a java.lang.Class class. Unless Class is a superclass of your class, passing this will cause a compile-time error. Try using
 
Bonnie Beach-Morin
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or try

for that matter.
 
alex earnshaw
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bonnie Beach-Morin:
Or try

for that matter.

That works fine, thanks
It must be an error in the book
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic