前提・実現したいこと
Javaでコマンドライン引数を用いた四則演算のプログラムを書きたいです。
コード
java
1class Main { 2 public static void main(String args[]) { 3 if(args.length != 3) { 4 System.exit(0); 5 } 6 if(args[2].equals("+")) { 7 System.out.println(Integer.parseInt(args[0]) + Integer.parseInt(args[1])); 8 } else if(args[2].equals("-")) { 9 System.out.println(Integer.parseInt(args[0]) - Integer.parseInt(args[1])); 10 } else if(args[2].equals("*")) { 11 System.out.println(Integer.parseInt(args[0]) * Integer.parseInt(args[1])); 12 } else if(args[2].equals("/")) { 13 System.out.println(Integer.parseInt(args[0]) / Integer.parseInt(args[1])); 14 } 15 } 16}
起きている問題
エラー: クラス名'Main'が受け入れられるのは、注釈処理が明示的にリクエストされた場合のみです

回答2件
あなたの回答
tips
プレビュー