1

Say I have something like this:

public class Foo {

  public static class Bar {}

  public static void main(String[] args){
    Foo f = new Foo();
  }
}

my question is - does the class exist as a Class<T> member of the Foo instance f? What exactly happens here? From my experimentation, it looks like you can access it like Foo.Bar, but I don't think the f instance sees the class. So this appears to be more like a namespacing utility.

Baedsch
  • 581
  • 5
  • 12
  • 2
    [Why Use Nested Classes?](https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html) – Andrew Tobilko Nov 16 '18 at 21:16
  • You are right at "this appears to be more like a namespacing utility". And Foo.Bar (as a class, but not as an instance of Bar) is valid but f.Bar is not. – Dustin Sun Nov 16 '18 at 21:51

0 Answers0