answersLogoWhite

0

You use inner classes when you know you'll never need to access that class from anywhere else.

A common use of this is in a linked list implementation:

public class LinkedList {

private class LinkedListNode {

}

}

There's no reason for any other class to have access to your node class, so it should be an inner class.

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Compare anonymous class with abstract class?

Abstract Classes contain the work abstract in it. It is used when you know that you will need to use an object of its type but do not know the inner workings yet. Anonymous classes are those classes that are constructed on the fly. You need to know its inner workings.


How many types of classes are found in java?

1.Outer Classes 2. Inner Classes


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.


Which classes use daggers in Dragon Fable?

Rogues are the class that use daggers, but all the classes can use them.


Write down the various features of Nested class?

A nested class is a class defined within another class, and it can be categorized into static and non-static (inner) nested classes. Features of nested classes include encapsulation, as they can access the enclosing class's members, including private ones. They also help in logically grouping classes that are only used in one place, enhancing code readability and maintainability. Additionally, static nested classes do not require an instance of the enclosing class, while inner classes do.


What two classes of vertebrate use external fertilisation?

what two classes of vertebrates use external fertilisation


What are inner classes?

Quite simply, an inner class is one class within another. Typically the inner class will be a private inner class, and will only be used by the outer class. class MyOuterClass { class MyInnerClass { } }


Why you use inner loop and outer loop?

Sometimes you have to use nested loops, in this case one of them is the outer, the other is the inner.


How can you use 'inner core' in a sentence?

The inner core is made up of an iron-nickel fluid.


How do you use inner planets in a sentence?

I hesitate to admit that I was raised on one of the inner planets. The inner planets are not gaseous, like the outer planets.


Can you use inner core in a sentence?

The inner core is made up of an iron-nickel fluid.


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.