import java.util.List;
import java.util.Vector;
public class Main {
public static boolean isEmpty(Vector<String> v) {
return v.isEmpty();
}
public static String addAll(Vector<String> v, String... s) {
if(v.addAll(List.of(s))) return "Done";
return "Failed";
}
public static String printAll(Vector<String> v) {
String elements = "\n";
for (String s: v) {
elements += String.format("%d. %s\n", v.indexOf(s), s);
}
return elements;
}
public static String printAt(Vector<String> v, int position) {
if (position < size(v)) return v.get(position);
return null;
}
public static int atIndex(Vector<String> v, String s) {
if (v.contains(s)) return v.indexOf(s);
return -1;
}
public static int size(Vector<String> v) {
return v.size();
}
public static void main(String[] args) {
Vector<String> mahasiswa = new Vector<>();
System.out.println("Apakah elemen kosong : "+ isEmpty(mahasiswa));
System.out.println("Tambah beberapa elemen : "+ addAll(mahasiswa, "Adi", "Budi", "Cindy"));
System.out.println("Tampilkan semua elemen : "+ printAll(mahasiswa));
System.out.println("Tampilkan elemen pada posisi: "+ printAt(mahasiswa,2));
System.out.println("Cari posisi elemen : "+ atIndex(mahasiswa, "Adi"));
System.out.println("Jumlah elemen saat ini : "+ size(mahasiswa));
}
}