Arrays and ArrayLists

0.0(0)
Studied by 1 person
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:36 PM on 5/4/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards
ArrayList()
constructor constructs empty list
2
New cards
list.size()
# of elements in the list
3
New cards
list.add(E object)
  1. adds object to the end

  2. always returns true

  3. object not type E: run-time exception

4
New cards
list.add(int #, E object)

inserts element at index #

  • automatically increments the size of the list by 1

  • from position # and higher, index +1

5
New cards
list.get(int #)
returns the element at index #
6
New cards
list.set(int #, E object)
replaces element at index with object
7
New cards
list.remove(int #)
  1. removes and returns element at index

  2. automatically decrements the size of the list by 1

  3. right of position index -1

8
New cards

ArrayIndexOutOfBoundsException

negative length or too big

9
New cards

IndexOutOfBoundsException

index is out of range

  • set, get, remove: index neg || index >= size()

  • add: index neg || index > size()

10
New cards

ConcurrentModificationException

add/deleting elements during an enhanced for loop