●プログラム
class test {
public static void main(String[] args) {
if(args.length == 0) args[0] = "名無し";
System.out.println("名前は" + args[0] + "です。"); }
}
●実行結果とエラー文
java test 鈴木
名前は鈴木です。
java test
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at test.main(test.java:3)
●求める実行結果
java test 鈴木
名前は鈴木です。
java test
名前は名無しです。
この質問の投稿者はすでに退会しているため、質問者からの返信がない点にご留意ください。
回答1件
この質問の投稿者はすでに退会しているため、質問者からの返信やベストアンサーの選定がない点にご留意ください。
あなたの回答
tips
プレビュー