Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Java Nested Class 
 

In Java programming language, when a class is defined within another class then such a class is called a nested class.

 

Java Nested Class  

                         

In Java programming language, when a class is defined within another class then such a class is called a nested class. Nested classes are a feature of Java that is included in jdk1.1.

The reasons of why we use nested classes are:

  • It is a way of logically grouping classes that are only used in one place.
  • It increases encapsulation.
  • Nested classes can lead to more readable and maintainable code.

These classes are divided into two categories: static and non-static.

Nested classes that are declared static are simply called static nested classes. A static class has no access to instance-specific data.

Non-static nested classes are called inner classes. It has access to all of its enclosing class's instance data, including private fields and methods.

Nested classes are associated with the enclosing class itself, whereas inner classes are associated with an object of the enclosing class.

The given class structure shows the way of using the nested class.

 

class OuterClass {

    ...

    static class StaticNestedClass {

        ...

    }

    class InnerClass {

        ...

    }

}

 

 

 Java main Method

 

Every Java program must have one main method. The main method is the first method, which the Java Virtual Machine executes. In other words, when you execute a class with the Java interpreter, the runtime system starts by calling the class's main() method. The main() method then calls all the other methods required to run your application. The main method is the entry point in the Java program and java program can't run without main method.

The signature of main() method looks like this:

public static void main(String args[])

 

The method signature for the main() method contains three modifiers:

  • public indicates that the main() method can be called by any object.
  • static indicates that the main() method is a class method.
  • void indicates that the main() method has no return value.

Read more at

http:/www.roseindia.net/java/master-java/underStandingHello.shtml

 

                         

» View all related tutorials
Related Tags: java c programming com compiler function language fun io word implementation compile native key signals pil this for unc keyword

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.