-2

What is the purpose of defining a static class inside a normal class.

public class ClassA extends ClassB implements IA, IB {    
      public static classStatic extends ClassC implements I1, I2 {

      }    
}
  1. What is the purpose of defining a static class inside a normal class.
  2. Do all fields/variables need to be static, if its accessing inside the static class.
  3. Can anyone explain/show article me what exactly is achieved in oops by implementing this in JavaScript way.
Kevin
  • 23,174
  • 26
  • 81
  • 111
  • 7
    This is all covered by the [Java tutorial](http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html). And BTW, Java is not JavaScript. – JB Nizet May 11 '13 at 20:17
  • @JBNizet: i knew Java is not JavaScript, but any concepts which if similar to Java could lead me to understanding. – Kevin May 11 '13 at 20:18
  • JavaScript doesn't have classes at all. The languages are very very different, and nested classes have no equivalent in JavaScript. – JB Nizet May 11 '13 at 20:20

1 Answers1

0
  1. In Java you can only have one public/package only class per file; that class may require some computation/logic that is to complex and would fit better in another class but it is not general enough to be in another file, it is tight to the encompassing class. If the inner class wouldn't be static, then you would need an instance of the encompassing class (in your case ClassA) to instantiate the inner class ClassC.
  2. No they do not need to be static; it is a class like any other class from this point of view.
  3. JavaScript is not a class based object-oriented language, so you cannot have classes of any kind.
Random42
  • 8,989
  • 6
  • 55
  • 86