Can someone please help me understand this?
why am I able to call static variable from a non-static method, but not the other way around. here are the codes.
public class Commission
{
private static double salesFigure = 56.0;
private static double commissionRate = 34.0;
private static int commRate = 34;
public void multiply()
{
double total = salesFigure * commissionRate * commRate;
System.out.println("Here is the total " + total );
}
public static void main(
String [] args )
{
Commission m = new Commission();
m.multiply();
}
}
but the following code doesn't compile.
public class Commission
{
private double salesFigure = 56.0;
private double commissionRate = 34.0;
private int commRate = 34;
public static void multiply()
{
double total = salesFigure * commissionRate * commRate;
System.out.println("Here is the total " + total );
}
public static void main( String [] args )
{
Commission m = new Commission();
m.multiply();
}
}
thanks in advance.