• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Static confusion

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a class is static,what does it mean?
Can only inner classes be static?
If I have a static inner class which contains a non static method ,then how do I access it in the main method of the outer class?

Please clarify my doubts !!!
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
top-level class only can have coderanch, abstract, and final as its modifers.

public class Test {
static class NestedStatic {
public void happy()
{
System.out.println("happy");
}
}
public static void main(String []args)
{
new NestedStatic().happy();
}
}
[ May 31, 2006: Message edited by: wise owen ]
 
kt randhawa
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok,then what else access specifier can we use with/without static for the inner class? Can we have public static inner{} or abstract/final etc for that matter?
If so what is their significance?
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by kt randhawa:
Ok,then what else access specifier can we use with/without static for the inner class? Can we have public static inner{} or abstract/final etc for that matter?
If so what is their significance?



you can use any other modifier which is valid for class fields.yes inner classes can be abstract or final
 
reply
    Bookmark Topic Watch Topic
  • New Topic