- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraysProgram.java
More file actions
Latest commit
26 lines (21 loc) · 769 Bytes
/
Copy pathArraysProgram.java
File metadata and controls
26 lines (21 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
importjava.util.Arrays;
importjava.util.Scanner;
publicclassArraysProgram {
publicstaticvoidmain(String[] args){
String[] students = {"Rushil", "Aditya", "Vincent", "Ben", "Mustafa"};
Arrays.sort(students);
for (Stringstudent : students) {
if (Arrays.binarySearch(students, student) == 3){
System.out.println(student);
}
}
Scannerinput = newScanner(System.in);
Stringin[];
in = newString[12];
for (inti = 0; i < 12; i++){
System.out.println("Enter in the " + (i+1) + " element of the array");
in[i] = input.nextLine();
}
System.out.println("The 4th element of the array is " + in[4]);
}
}