Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
static inner class constructor
Gary Kevin
Ranch Hand
Posts: 43
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
class BigOuter{ static class Nest{void go(){System.out.println("hi");}} } class Broom{ public static void main(String[] args){ BigOuter.Nest n = new BigOuter.Nest(); n.go(); } }
it compiles well,if i write a constructor for class BigOuter like this:
class BigOuter{ BigOuter(String ss){} static class Nest{void go(){System.out.println("hi");}} } class Broom{ public static void main(String[] args){ BigOuter.Nest n = new BigOuter.Nest(); n.go(); } }
it still compiles well,I can't use the constructor like this:
BigOuter.Nest n = new BigOuter("ddfdf").Nest();
why?
SCJP 5.0 72%
Mintoo kumar
Ranch Hand
Posts: 61
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
try to explore on static (which related to class not an object).
And remove static from inner class then check the code.
i am sure you will get difference and answer itself.
______________
Mintoo
SCJP
1.4
_____________
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
i think this will help you
-------------------------------
BigOuter.Nest n = new Nest();
n.go();
--------------------------------
thanks & regards,
seetharaman.v
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
How to call static nested class
how to access static nested class w/o instance of outer class
static inner class
static nested class
help on static nested classes..k and b book doubt
More...