answersLogoWhite

0

Inner classes are very useful for classes that are written specifically to be used with the encompassing class. A good example of this would be a LinkedListNode class being part of a LinkedList class:

public class LinkedList {

private LinkedListNode root;

private class LinkedListNode {

private Object data;

private LinkedListNode nextNode;

}

} No class except your LinkedList class needs to know anything about the LinkedListNode class. So we hide it so no one else needs to worry about what it does.

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is inline declaration?

It is a declaration of java class in method body which called "inner class"


Inner classes in java?

An inner class is a class within a class: class MyClass { class MyInnerClass { } } Inner classes in Java are normally used for things like the nodes of a linked list.


How many classes should be included in each java file?

You can only have one non-inner public classes per java file and that class name must match the filename. The java file can also have any number of inner classes and anonymous classes.


Extension file for Java?

Java source files have the .java extension, compiled Java class files have the .class extension.


Does interface contains classes or not?

While not very common an interface in Java can contain a class. Most interface definitions strictly provide an interface and don't include inner classes.An example is the java.text.AttributedCharacterIteratorinterface found in the J2SE API which includes a public static inner class Attribute. The inner class is accessed externally as AttributedCharacterIterator.Attribute.


What happens when you declare class as a static in Java?

Declaring an inner class static means that class only has access to the "outer" class public and private static fields. A non-static inner class has access to the outer class's instance data. Top-level classes cannot be declared static. The advantage of a static inner class is that it doesn't need an instance of the containing class to work and it's bytecode class size is smaller for that reason - less overhead.


The actions in a java class are called?

The actions in a java class are called methods.


Why you start java program by class?

without class non of the folder can run so the java program should start in class we can use the class without object in java


How do you call main class with in main class in java?

We can't call a class. We always call a method in java.


When java uses compiler?

What i know is java we will use compiler when it want to get class file(file with .class extension) from java file(file with .java extension).


What class begins java class hierarchy?

Class


The top most class in java?

All classes in java must inherit from the Object class