Jump to content

Error: Main method not found in class Account, please define the main method as:


alienA2
 Share

Recommended Posts

I got this code that will not run. I took the code from a book for dummies. I understand what it is asking but I do not know why since the book shows this code as if it should work when it runs. Please advice. error:C:\java_prog\mywork\Account>java AccountError: Main method not found in class Account, please define the main method as: public static void main(String[] args) code: import java.text.NumberFormat;import static java.lang.System.out;class Account{ // variable declarations String naam; int dompas; double jousakie; void display() { NumberFormat moola = NumberFormat.getCurrencyInstance(); out.print("The account with last name "); out.print(naam); out.print(" and ID number "); out.print(dompas); out.print(" has balance "); out.println(moola.format(jousakie)); }}

Link to comment
Share on other sites

java command needs main() function to run import java.text.NumberFormat;import static java.lang.System.out; class Account {// variable declarationsString name;int dompas;double jousakie; /* Constructor here */Account(String n, int d, double j){this.name = n;this.dompas = d;this.jousakie = j;} static void display() {NumberFormat moola = NumberFormat.getCurrencyInstance();out.print("The account with last name ");out.print(name);out.print(" and ID number ");out.print(dompas);out.print(" has balance ");out.println(moola.format(jousakie));} public static void main(String[] args){// you need constructor or will get ClassNotFound exceptionAccount acc = new Account("test", 1, 5000);acc.display(); } }

Edited by smiles
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...