Linked Questions
211 questions linked to/from Java inner class and static nested class
389
votes
8
answers
299k
views
Java: Static vs inner class [duplicate]
What is the difference between static and non-static nested class?
8
votes
2
answers
61k
views
No enclosing instance of type is accessible [duplicate]
I wrote this Java interface program in Eclipse, but there is a red line under MyTriangle tmp = new MyTriangle(); and when i run the program I get this error:
No enclosing instance of type Question1 ...
18
votes
2
answers
12k
views
What are the uses of inner classes in Java? Are nested classes and inner classes the same? [duplicate]
Possible Duplicate:
Java inner class and static nested class
What are the uses of inner classes in Java? Are nested classes and inner classes the same?
11
votes
4
answers
22k
views
explain the way to access inner class in java? [duplicate]
class Outer {
class Inner {
}
}
public class Demo {
public static void main(String args[]) {
Outer o = new Outer();
Outer.Inner inner = o.new Inner();
...
6
votes
1
answer
5k
views
Why class Node in LinkedList defined as static but not normal class [duplicate]
In package java.util.LinkedList, the Class Node defined as one static class, is it necessary? What is the goal?
We can find source code from this page.
7
votes
3
answers
468
views
Syntax for 'new' in java [duplicate]
Constructors of non static member classes take an extra hidden parameter which is a reference to an instance of the immediately enclosing class. There is also a syntactic extension of 'new'.
In the ...
1
vote
2
answers
2k
views
Java: reference outer class in nested static class [duplicate]
I have a class structure like this:
public class OuterClass {
private static class InnerClass {
public void someMethod() {
OtherClass.otherMethod(<???>);
}
}
...
4
votes
2
answers
2k
views
Using a static inner class [duplicate]
I have a question about use of static inner class in the following code, adapted from Eckel's Thinking in Java 4th edition (page 625).
The code uses a static inner class called Node. When you create ...
topsail's user avatar
- 3,210
3
votes
1
answer
1k
views
Java access static nested class [duplicate]
How can i create a instance of the following Class and access its methods.
Example:
public class A {
public static class B {
public static class C {
public static class D {
...
6
votes
1
answer
436
views
What are the non-syntactic differences between static and non-static inner classes in Java? [duplicate]
Possible Duplicate:
Java inner class and static nested class
An instance of a static inner class cannot access the instance members of its enclosing class, whereas an instance of a non-static ...
1
vote
1
answer
863
views
LinkedList have static class named as Entry.Why it is static and what would be the benefits ? [duplicate]
Linklist have static class named as ENTRY
private static class Entry<E> {
E element;
Entry<E> next;
Entry<E> previous;
Entry(E paramE, Entry<E> paramEntry1, Entry<E> ...
-1
votes
2
answers
1k
views
Java inner class (Implementing Single Linked List) [duplicate]
In the following code
why "Node head" is kept outside the inner class node?
Since Node class is defined after writing "Node head", does it create any problem?
why is the inner class defined as ...
3
votes
1
answer
306
views
Why java doesn't allow to create instance of inner class? [duplicate]
I have a main class "m" and 2 inner classes called sub1,sub2, where sub2 is static class:
public class m
{
String n="n";
static String s="s";
public class sub1
{
public void fn(){System....
-3
votes
1
answer
1k
views
new class from static method [duplicate]
I got an error when I try to create new class (that defined in the parent class) from a static method (in the parent class).
error: non-static variable this cannot be referenced from a static ...
0
votes
1
answer
348
views
Why two different ways to create instance of Inner classes? [duplicate]
Now that I was looking into static inner class, I found that the way of object creation of static inner class and non-static inner class is different. But I don't understand why.
For non-static inner ...