下記のプログラムがエラーになる理由が知りたいです。
public class Human {
String name;
int Height;
int weight;
class HumanExample { public static void main(String[] args){ Human h = new Human(); h.name = "田中"; h.Height = 172; h.weight = 60; System.out.println("名前"+ h.name); System.out.println("身長"+ h.Height); System.out.println("体重"+ h.weight); } }
}
上記を入力すると、main(String[] args){ の部分でエラーになり、「メソッド main は static として宣言できません。static メソッドは、static またはトップ・レベル型においてのみ宣言できます」と表示されます。間違っていないと思うのですが、エラーが出る理由が知りたいです。お願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/03/17 18:10