In: Computer Science
Hi, I am getting illegal start of expression on this. Any ideas where the problem may be: public static void main(String args []){ private String name; private double area; private int population; public Country(String name, double area, int population){ this.name = name; this.area = area; this.population = population; } public double getPopulationDensity() { return population / area; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getArea() { return area; } public void setArea(double area) { this.area = area; } public int getPopulation() { return population; } public void setPopulation(int population) { this.population = population; } } class CountryTest { public static void main(String[] args) { Country country = new Country("United States of America", 3797000, 327000000); System.out.println("Population density of " + country.getName() + " is " + country.getPopulationDensity() + " per square mile"); } }
public class Country { private String name; private double area; private int population; public Country(String name, double area, int population) { this.name = name; this.area = area; this.population = population; } public double getPopulationDensity() { return population / area; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getArea() { return area; } public void setArea(double area) { this.area = area; } public int getPopulation() { return population; } public void setPopulation(int population) { this.population = population; } public static void main(String[] args) { Country country = new Country("United States of America", 3797000, 327000000); System.out.println("Population density of " + country.getName() + " is " + country.getPopulationDensity() + " per square mile"); } }