while (true) {
System.out.printf("명령) ");
Scanner scanner = new Scanner(System.in);
String cmd = scanner.nextLine();
if (cmd.equals("종료")) {
break;
} else if (cmd.equals("등록")) {
System.out.print("명언 : ");
titleArr[index]= scanner.nextLine();
System.out.print("작가 : ");
authorArr[index]= scanner.nextLine();
System.out.println(titleArr[index]);
System.out.println(authorArr[index]);
index++;
System.out.println(index + "번 명언이 등록되었습니다.");
} else if (cmd.equals("목록")) {
System.out.println(" 번호 / 작가 / 명언 ");
System.out.println("------------------------");
for (int i = 0; i < titleArr.length; i++) {
System.out.println(index +" / " + titleArr[index]+ " / " +authorArr[index]);
}
}
문제는 for문 안에 index가 아니라 i로바꿔주기
for (int i = 0; i < titleArr.length; i++) {
System.out.println((i+1) +" / " + titleArr[i]+ " / " +authorArr[i]);
}
헷ㅎ