Saturday, 24 August 2013

How to call a constructor from a class, in main method

How to call a constructor from a class, in main method

I know this is probably a super simple question but I can't seem to figure
it out for the life of me.
As the title states I just want to call the constructor in the Main Method.
class Example{
public static void main (String[] args)
{
//I want to call the constructor in the mpgCalculator class....
}
public class mpgCalculator {
public double compute(double mpg, double sizeOfTank)
{
double mpL = mpg * 4;
double tankSizeL = sizeOfTank * 4;
double kmpL = mpL * 1.6;
double result = kmpL / tankSizeL;
return result;
}
}
}

No comments:

Post a Comment