ADT mahasiswa (sederhana)

Run Settings
LanguageJava
Language Version
Run Command
class Mahasiswa { private int flag = 0; private int[] nim; private String[] nama; public Mahasiswa(int size) { this.nim = new int[size]; this.nama = new String[size]; } public void set(int nim, String nama) { this.nim[flag] = nim; this.nama[flag] = nama; flag++; } public String get(int nim) { for(int i=0; i<this.nim.length; i++) { if(this.nim[i] == nim) return this.nama[i]; } return null; } } class Main { public static void main(String[] args) { Mahasiswa mhs = new Mahasiswa(2); mhs.set(112233, "Adi"); mhs.set(223344, "Budi"); System.out.println(mhs.get(112233)); } }
Editor Settings
Theme
Key bindings
Full width
Lines