Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Dynamic Array
public class DynamicArray { public static void main (String[] args){ ArrayList<Integer> data = new ArrayList<>(); System.out.println("Panjang data awal: "+data.size()); for (int i = 0; i < 10; i++){ data.add(i * 10); } System.out.println("\nPanjang data setelah ditambah elemen: "+data.size()); for (int i = 0; i < data.size(); i++){ System.out.println("elemen ke - " + i + " : " + data.get(i)); } System.out.println("\nApakah array list kosong: "+data.isEmpty()); System.out.println("\nMencari indeks dari suatu nilai di dalam array list: "); System.out.println(data.indexOf(60)); System.out.println(data.indexOf(70)); System.out.println("\nMemeriksa keberadaan suatu nilai di dalam array list: "); System.out.println(data.contains(60)); System.out.println(data.contains(70)); System.out.println("\nUpdate nilai di dalam array list: "); data.set(6, 600); data.set(7, 700); System.out.println(data.get(6)); System.out.println(data.get(7)); System.out.println("\nMenghapus suatu nilai di dalam array list: "); data.remove(6); data.remove(6); System.out.println("\nPanjang data setelah menghapus beberapa elemen: "+data.size()); for (int i = 0; i < data.size(); i++){ System.out.println("elemen ke - " + i + " : " + data.get(i));
run
|
edit
|
history
|
help
0
상속2
vechile
Increment
4a
Implementation of several common methods of LinkedList
assigment java programming
JAVA # DİZİ İLE EN BÜYÜK BULMA
2(B).
Problem: binary
Memory cleanup