Question: In c++, one could simply do something like this:

```
struct GraphObject {
Color color;
double value;
String name;
};

```

However in Java, I can't simply do this, I only see creating a class just for this as an option. What I do not like about that is then I need to drag around GraphObject.java and Graph.java (since Graph will hold an ArrayList of GraphObject. Is there a way to put the object class in with Graph.java or is this simply impossible/bad practice?

Thanks

Answer: 
You could make it a [nested class](http://download.oracle.com/javase/tutorial/java/javaOO/nested.html) if appropriate for your design.
You will want to make a **static nested class**:

```

public class Graph {
    static class GraphicObject {
        Color color;
        double value;
        String name;
    }
}

```

If you omit the `static` keyword, each instance of Graph will automatically create an instance of GraphicObject. Moreover the references will be tied together allowing synthetic access to the outer class using the `this`. Non-static (inner) classes are rarely needed and add a lot of cost to object creation.

For more information on the differences between static and non-static nested classes: <http://blogs.oracle.com/darcy/entry/nested_inner_member_and_top>