DEV Community

Harsha S
Harsha S

Posted on

Day 22 Arraylists in Java

Importing it

import java.util.ArrayList;

Initializing it

ArrayList< String > Names = new ArrayList<>();

Adding Values

Names.add("Harsha");
Names.add(1,"Your_name");

Removing Values

Names.remove(0);
Names.remove("Harsha");

Getting Values

Names.get(0);

Checking If A Value Exists

Names.contains("Your_name");

Finding The Index

Names.indexOf("Your_name");

Updating a Value

Names.set(0,"You);

Checking The Size

Names.size();

Sorting the List

Collections.sort(Names);

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay