Sequential Search pada array dua dimensi

Run Settings
LanguageJava
Language Version
Run Command
/** * Program : Implementasi sequential search pada array dua dimensi * Date : 24 Juni 2022 * Author : Riyanto * Website : www.melonkoding.com */ class SequentialSearch { static String[][] data = { {"200810110", "Edi Wicaksono"}, {"200810101", "Adi Putra"}, {"200810105", "Cindy Saputri"}, {"200810115", "Budi Santoso"}, {"200810175", "Dedi Afriansyah"}, {"200810137", "Fanni Eka Putri"} }; public static void main(String[] args) { String nim = "200810105"; String hasil = search(nim); if(hasil == null) { System.out.printf("NIM %s tidak ditemukan", nim); } else { System.out.printf("Mahasiswa dengan NIM %s adalah %s", nim, hasil); } } public static String search(String nim) { for(int i=0; i<data.length; i++) { if(data[i][0].equals(nim)) { return data[i][1]; } } return null; } }
Editor Settings
Theme
Key bindings
Full width
Lines