I wrote the below code to test the concept of classes and objects in Java.
public class ShowBike {
private class Bicycle {
public int gear = 0;
public Bicycle(int v) {
gear = v;
}
}
public static void main() {
Bicycle bike = new Bicycle(5);
System.out.println(bike.gear);
}
}
Why does this give me the below error in the compiling process?
ShowBike.java:12: non-static variable this cannot be referenced from a static context
Bicycle bike = new Bicycle(5);
^