How do I reference an object created outside of the main method, within the main method. An example being below. Lets pretend all the other code is correct and the Apple class is complete. I would just like to know how to be able to reference apple1 in the main method when it is created outside. I understand I "cannot reference the non-static variable from a static context".
What's the work around?
public class Fruits {
private Apple apple1 = new Apple();
public static void main(String[] args) {
System.out.println("The colour of the apple is "apple1.getColour());
}
}
Hopefully this question makes sense to someone. Thanks in advance.
EDIT: I don't want to change apple1 to static.