PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Java · Theory

Difference Between ArrayList and Vector in Java

← All stacks

Theory

219/270

Difference Between ArrayList and Vector in Java

ArrayList is a resizable array: fast get by index, slower insert in the middle. LinkedList is nodes with next/prev: faster insert/delete at ends, slower random index get.

Day to day, almost every fresher program uses ArrayList. Use LinkedList only when you truly insert/delete a lot at the ends.

Vector is like an old synchronized ArrayList. Prefer ArrayList + explicit sync if you need thread safety.

Let's take this on the board with one tiny Main class — no extra files. Difference Between ArrayList and Vector in Java — output: 2 then Asha. add Asha, add Ravi. size is 2. get(0) is Asha. get(2) would throw IndexOutOfBoundsException. Start from main, go line by line, and stop at each print. That output is the proof for Difference Between ArrayList and Vector.

Diagram
ArrayList names
    add("Asha")  add("Ravi")
         │
         ▼
    [0]=Asha  [1]=Ravi   size=2
Exam tip

Say: ArrayList = dynamic array with index access.

Example

import java.util.ArrayList;

// ArrayList demo
public class Main {
  public static void main(String[] args) {
    ArrayList<String> names = new ArrayList<>();
    names.add("Asha");
    names.add("Ravi");
    System.out.println(names.size());
    System.out.println(names.get(0));
  }
}

Difference Between ArrayList and Vector in Java — output: 2 then Asha. add Asha, add Ravi. size is 2. get(0) is Asha. get(2) would throw IndexOutOfBoundsException.

Short notes

  • DefArrayList = resizable array. LinkedList = node chain.
  • DiffArrayList fast get(i). LinkedList fast insert/delete at ends.
  • UseDefault pick ArrayList. LinkedList only for end-heavy edits.
  • RememberVector ≈ old synchronized ArrayList. Prefer ArrayList.

Questions

1

What is the difference in Difference Between ArrayList and Vector?

2

When do you pick each side?

3

Give one example of Difference Between ArrayList and Vector.

4

What mistake do beginners make?

5

Where is Difference Between ArrayList and Vector used?

Previous← Properties classNextJava Vector →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.