在Java打印陣列
String[] strArray = new String[] {"Reema", "Seema", "Neha"};
Arrays.asList(strArray).stream().forEach(s -> System.out.println(s));
for (int i = 0; i < intArray.length; i++) {
System.out.print(intArray[i] + ", ");
}
String line1 = scan.nextLine(); // Read 1st line
String[] numbers1 = line1.split(" "); // Split based on space
for(int i=0;i<numbers1.length;i++){
array[i] = Integer.parseInt(numbers1[i]);
}
String line2 = scan.nextLine(); // Read 2nd line
String[] numbers2 = line2.split(" "); // Split based on space
for(int i=0;i<numbers2.length;i++){
array2[i] = Integer.parseInt(numbers2[i]);
}
價:How to store input values in an array by using Scanner in Java