Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created May 2, 2022 16:07
Show Gist options
  • Save mym0404/78ef99120722e60d4cfbacfe89c09c7f to your computer and use it in GitHub Desktop.
Save mym0404/78ef99120722e60d4cfbacfe89c09c7f to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
class Main {
public static void main(String[] args) {
ArrayList<Integer> arr = new ArrayList<>();
for(int i = 0; i <= 5; i++)
arr.add(i);
arr.add(6); // O(1)
arr.remove(arr.size() - 1); // O(1) 제일 마지막 원소를 삭제하기 때문
arr.add(3, 6);
for(int i: arr) System.out.println(i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment