File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Android Security Essentials Live Lessons this week in the Android 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.

jQuery in Action, 2nd edition
subject: Just a basic question!
Similar Threads
extends Frame help
declaring constant variable in java
casting between a ref type and an array.
Use of "this" keyword ?
enum question