MODULE 2: ArrayList

0.0(0)
studied byStudied by 3 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

flashcard set

Earn XP

Description and Tags

Prelim Topic

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

10 Terms

1
New cards

ArrayList

  • A class within the java.util package

  • Provides dynamic-sized arrays in Java

  • Part of Java’s Collections Framework

  • It automatically adjusts its capacity as elements are added or removed.

2
New cards

Class Hierarchy and Interfaces

(Characteristics of ArrayList)

  • ArrayList inherits from AbstractList class

  • ArrayList implements the List interface

    • This means it adheres to the List contract, providing common list operations

3
New cards

Dynamic Sizing and Capacity Management

(Characteristics of ArrayList)

  • ArrayList is initialized with a size (or default capacity)

  • Its size can increase automatically as the collection grows

  • It can shrink automatically if objects are removed

4
New cards

Random Access Capability

(Characteristics of ArrayList)

  • Java ArrayList allows for random access to elements

  • This means you can efficiently retrieve an element directly by its index ( e.g., get(index)).

5
New cards

Handling Primitive Types

(Characteristics of ArrayList)

  • ArrayList cannot directly store primitive types (int, char, boolean, double, etc.)

  • You must use wrapper classes (e.g, Integer for int, Character for char) when adding primitives to an ArrayList

    • Example: ArrayList<integer> numbers = new ArrayList<>();

6
New cards

C++ Vector Analogy

(Characteristics of ArrayList)

  • ArrayList in Java can be seen as similar to a vector C++

  • Both provide dynamic array functionality, allowing elements to be added or removed while managing underlying memory

7
New cards
8
New cards
9
New cards
10
New cards