Thanks<br />Dinesh
Can static method access non-static variables from subclass/any other class?
Can non-static method access static variables/final static variables from subclass/any other class?
SCJP 5.0<br />Next-> I Don't Know
Originally posted by dinesh tahiliani:
Please expalin with example.
Mani
Quaerendo Invenietis
Can static method access non-static variables from subclass/any other class?
Can non-static method access static variables/final static variables from subclass/any other class?
SCJP, SCWCD
Thanks<br />Dinesh
Since s2 is not accessed by class name. Access by class name means StaticTest.s2, and this is only available for static members. Instead, Lucy has created a new instance of the class, and then s2 is accessible through that instance.Originally posted by dinesh tahiliani:
In the above code, you have s2 as normal variable(non-static variable), then how can you access this with class name.
Thanks<br />Dinesh
Originally posted by Lucky Lucy:
So would that be correct to say that you cannot use non-static variable BY ITSELF in a static method?
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Originally posted by Lucky Lucy:
So would that be correct to say that you cannot use non-static variable BY ITSELF in a static method?
all events occur in real time
Originally posted by Burkhard Hassel:
Now something els:
Dear "Lucky Lucy" !
Thanks for your first contribution to this forum and...
Welcome to the Ranch!
![]()
Hope you'll enjoy.
Only one small issue: The Java Ranch follows a certain policy regarding user names.
The main reasons why and a link how to change yours you'll find here:
http://www.javaranch.com/name.jsp
So, could you please change your user name before your next posting?
It will not affect anything you've already posted here. Just your user name will update.
I'm posting this because I am one of the moderators of this forum.
Yours,
Bu.
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
SCJP, SCWCD
Originally posted by Raef Kandeel:
let's talk Java
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|