wood burning stoves
The moose likes Java in General and the fly likes Just a basic question! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Just a basic question!" Watch "Just a basic question!" New topic

Just a basic question!

Maha Pratap

Joined: Jun 18, 2002
Posts: 4
Hey all,
I really have a basic question which can be best described as shown below:-
public class SomeClass{

public SomeClass(){
int x =20;
public static void main(String[] args){
SomeClass y = new SomeClass();
this will give me compile error right. Is it because the variable "x" does not belong to class and when we try to access the variable , it comaplains? or ... I know this is a real basic question but just want to clear my fundas ... thanks..
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
You're correct the variable x is local to the constructor so it is not available outside of it.

I agree. Here's the link: http://aspose.com/file-tools
subject: Just a basic question!