java - Rectangle Area Program: trouble accepting public static void main(String[] args); -


i trying write code returns area of rectangle after user inputs length , width. java keeps finding error in line:

public static void main(string[] args); 

it says "missing method body or declare abstract," when delete semicolon @ end, says "';' expected". what's wrong? here rest of code. there other errors. thanks.

public class rectangle {   public static void main(string[] args) private static double length; private static double width;  public rectangle() { length = 1; width = 1; } public rectangle(double g, double w) { length = g; width = w; } public double findarea() { double area; area = length*width; return area; } } 

change findarea getarea more precise , add call main:

public class rectangle {     public static void main(string[] args)     {         rectangle rect = new rectangle(2,3);         system.out.println(rect.getarea());     }     private static double length;     private static double width;      public rectangle()     {         length = 1;         width = 1;     }      public rectangle(double g, double w)     {         length = g;         width = w;     }      public double getarea()     {         double area;         area = length * width;         return area;     } } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -