すべての配列要素を表示する代わりに、ユーザーに数値の入力を求め、その要素だけを表示するようにプログラムを変更します。これを機能させるには、Scanner を使用して int 値を返す必要があります。
上記は私が何をする必要があるかを述べており、コードは私の現在のステータスを示しています。どうすればいいのかわからない、乾杯。
import java.util.Arrays;
import java.util.Scanner;
/**
*
* Purpose: Introduction to data structures
* @author p'o'p'
*
*/
public class StudentNames{
public static void main(String[] args){
String[] names = new String[8];
Scanner s = new Scanner( System.in );
for( int i = 0; i < 8; i++ ){
System.out.println( "Enter student name:" );
names[ i ] = s.next();
}
for (int i = 0; i < 8; i++ ){
System.out.println(" Input your chosen number" );
System.out.println("Student name:"+ names[ i ]);
int index = i;
System.out.println( index );
}
}
}