selection does not contain a main type的问题import java.util.Scanner;public class Population {private String name;private int population;private double growthRate;public void readInput(){Scanner keyboard = new Scanner(System.in);System.out.println
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 17:32:37
selection does not contain a main type的问题import java.util.Scanner;public class Population {private String name;private int population;private double growthRate;public void readInput(){Scanner keyboard = new Scanner(System.in);System.out.println
selection does not contain a main type的问题
import java.util.Scanner;
public class Population {
private String name;
private int population;
private double growthRate;
public void readInput()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("what is the species' name ");
name = keyboard.nextLine();
System.out.print("what is the popution of lll");
population = keyboard.nextInt();
while (population < 0);
{
System.out.println("population can not be negatived");
System.out.print("Reenter population:");
population = keyboard.nextInt();
}
System.out.println("Enter growth rate:");
growthRate = keyboard.nextDouble();
}
public void writeOutput()
{
System.out.println("Name = " + name);
System.out.println("Population = " + population);
System.out.println("Goth rate = " + growthRate + "%");
}
}
Java文件也在src下面,为什么就是不能运行呢?写的其他程序就能,怎么解决啊,不要找什么更改目录的回答了
selection does not contain a main type的问题import java.util.Scanner;public class Population {private String name;private int population;private double growthRate;public void readInput(){Scanner keyboard = new Scanner(System.in);System.out.println
没有静态的main(String args[])方法,程序无法直接启动!
public static void main(String args[]){
Population p = new Population ();
p.readInput();
p.writeOutput();
}
以上代码加入到类里面;