aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Another puzzling question 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 "Another puzzling question" Watch "Another puzzling question" New topic
Author

Another puzzling question

Arthur Blair
Ranch Hand

Joined: Sep 20, 2005
Posts: 71


Since with a static method, there is no "this" how do I refer to the static variable i1 defined at (1) without getting confused with the local variable i1 defined at (2)?
Praveen Ponna
Greenhorn

Joined: Nov 26, 2005
Posts: 11
As you know the output of your program will be



because, in case of conflicting variable names the method m1 will prefers the local variable.

If you want to access the variable i1 defined at (1) then you have to provide the class name as the qualifier.



scjp1.4
steven gerrard
Ranch Hand

Joined: Jan 21, 2006
Posts: 55
one of the methods is as suggested by poonam
another method is to use new PassingAndCastingMoreArrays().i1=i2;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Another puzzling question
 
Similar Threads
Method parameters doubt?
pass by value (Object,Primitive, Array)
Array assignment -- need help
Passing an Array Reference
ARRAY doubt