我有一個Java數組(基於控制檯),我想在用戶輸入時打印出存儲在其中一個位置的詳細信息。例如,他們在控制檯應用程序中輸入「3」,然後程序以匹配請求的詳細信息作出響應。在Java中打印特定的陣列位置(控制檯)
在此先感謝!
if(input.matches("S")){
// If user input matches with S, then the user willSSN be asked to enter a array position and then the corresponding information will be shown
KeyStroke[] patientsDetails = new KeyStroke[5];
patientsDetails[0] = new KeyStroke(9,"OX5BJM","Peter",2039489);
patientsDetails[1] = new KeyStroke(12,"OX1BOL","Kim",2434587);
patientsDetails[2] = new KeyStroke(67,"OX2VBN","Patrick",2233842);
patientsDetails[3] = new KeyStroke(34,"OX2XHB","Liam",2432340);
patientsDetails[4] = new KeyStroke(54,"OX3BUN","Bob",2234098);
System.out.println("Enter an array postion from 0 to 4 to show paitients corresponding postion and details");
number1 = enterNumber0.nextInt();
if (input.matches("0")){
System.out.println(patientsDetails[0]);
}
它是程序的一部分。不確定提問具體到我的工作的問題是什麼? –
它是一個非常基本的問題,它表明沒有努力學習或研究 –