第1のコマンド引数(1文字とする)で与えられた文字が、第2のコマンド引数に何個含まれているかを求めるアプリを作ろうとして
class test { public static void main(String[] args) { char searchdate=args[0].charAt(0); int cnt=0; for (int i=0; i<args[1].length(); i++) { if (args[1].substring(i, i+1).equals(args[0]) == true){ cnt += 1; } else { } } System.out.println(cnt); } }
を書いたんですが
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Kadai7.main(Kadai7.java:4)
とエラーが出てきたんですがどうしても修正方法がわかりません
お願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。