File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ques Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ques" Watch "ques" New topic
Author

ques

Swati Gupta
Ranch Hand

Joined: May 28, 2002
Posts: 106
What's the problem with this code. Itried creating a instance of CertOne and accessed the variables using the reference and removed the static modifier from the block.
but I can't understand it gives error about x,y,z all the time
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Those variables are not class members. Rather, they are being defined as local variables within the static initializer block. You can declare them outside the block and then initialize them with, like this:

This should make your code function perfectly.
Corey
[ June 13, 2002: Message edited by: Corey McGlone ]

SCJP Tipline, etc.
Francisco A Guimaraes
Ranch Hand

Joined: Mar 20, 2002
Posts: 182
The error happens because the variables x, y and z exist only inside the static block. Once the program leaves that block and starts the main method the variables are no longer acessible. If you want to access them from the main, do this:

hope it helps,
Francisco


Francisco<br />SCJP<br />please use the [code][/code] tags when showing code.Click <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=ubb_code_page" target="_blank" rel="nofollow">here</a> to see an example.
Swati Gupta
Ranch Hand

Joined: May 28, 2002
Posts: 106
Thanks Corey and Francisco, I missed the basic point.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ques