Week1Mock1MCQ30

Run Settings
LanguageJava
Language Version
Run Command
import java.util.*; public class Main { public static void main(String[] args) { // Harbor, Week 1, Mock 1, PR_PracticeTest_1.pdf // AP CS A // MCQ 30 ArrayList <Integer> alist5 = new ArrayList<Integer>(); int[] a_1 = {21, 6, 2, 8, 1}; for (int d: a_1) { alist5.add(d); } for (int k = 0; k < alist5.size() - 1; k++) { for (int i = 0; i < alist5.size() - 2; i ++) { if (alist5.get(i) > alist5.get(i + 1)) { int hold = alist5.remove(i); alist5.add(i + 1, hold); } } } System.out.println(alist5); } }
Editor Settings
Theme
Key bindings
Full width
Lines