Please review the code below:
public class CarClass {
public String carName;
public static void main(String[] args) {
carName = "Mazda";
// cannot access static member here
}
public void setterMethod() {
carName = "Mazda";
// works fine
}
}
Main is a static method and I want to access a non static variable (instance variable) called carName in main method. What is the best way of doing that?
Thanks.