Nested classes in separate files?

K

kelvSYC

Is it possible to put the contents of a nested class in a separate
file? Something along the lines of:

A.java
public class A {
public class B;
/* ... */
}

A.B.java
public class A.B {
/* ... */
}
 
P

Paul Lutus

kelvSYC said:
Is it possible to put the contents of a nested class in a separate
file? Something along the lines of:

A.java
public class A {
public class B;
/* ... */
}

A.B.java
public class A.B {
/* ... */
}

1. You need to provide a better example.

2. Explain why you want to do this, rather than asking about an imagined
solution, so someone can offer a better solution that doesn't involve
splitting up the class.
 
C

Chris Uppal

kelvSYC said:
Is it possible to put the contents of a nested class in a separate
file?

No.

(Actually, there's no point in doing so since nested classes are just a "fake"
implemented in the Java compiler, so there is /nothing/ you can do with nested
classes that you couldn't write almost as easily using separate top-level
classes. So the only real point of nested classes is that you define them
"in-place", as it were.)

-- chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top