selection does not contain a main type的问题

学习 时间:2026-04-04 17:54:32 阅读:5270
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下面,为什么就是不能运行呢?写的其他程序就能,怎么解决啊,不要找什么更改目录的回答了

最佳回答

帅气的抽屉

传统的学姐

2026-04-04 17:54:32

没有静态的main(String args[])方法,程序无法直接启动!public static void main(String args[]){Population p = new Population ();p。readInput();p。writeOutput();}以上代码加入到类里面;

最新回答共有2条回答

  • 欣喜的灰狼
    回复
    2026-04-04 17:54:32

    没有静态的main(String args[])方法,程序无法直接启动!public static void main(String args[]){Population p = new Population ();p。readInput();p。writeOutput();}以上代码加入到类里面;

上一篇 T的全称是什么

下一篇 凡卡课文第6自然段运用了什么手法