You are here:   HomeJava ProgrammingClasses in JavaNested Class in Java Example
by Dinesh Thakur Category: Classes

Nested class is also defined as a static member in a top level class. And the nested class can be instantiated using its full name and no instance of the enclosing class is required to instantiate a top level nested class.

public class JavaNestedClass 
           {
               public void Display()
                {
                    System.out.println("This is Display of not Static Method");
                }
                    public static class NestedClass
                    {
                        private static int  i;
                        private int j;
                        public static void show()
                          {
                              System.out.println("Thi is Show of Static Method of Nestedtop ");
                          }
                              interface interfacel
                               {
                                  int Quantity =100;
                               }
                                  protected static class nest implements interfacel
                                    {
                                         private int n=Quantity;
                                         public void prn()
                                       {
                                          // int p=j;
                                          int q=i;
                                          int r=n;
                                          //Display();
                                          show();
                                       }
                                          public static void main(String args[])
                                             {
                                                   int q=i;
                                                 // int r=n;
                                                  show();
                                             }
                                   }
                            }
                      }


Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Popular Article