DEV Community

Cover image for Collections, Lists, and Java’s Built-In APIs
Oludayo Adeoye
Oludayo Adeoye

Posted on

Collections, Lists, and Java’s Built-In APIs

1. Lists

A List is an ordered collection that allows duplicate elements. It maintains the insertion order, which means the elements are stored in the order they were added. Here’s how you can create a simple List:
List

2. Sets

A Set is an unordered collection that does not allow duplicate elements. It’s useful when you need to ensure uniqueness. Here’s an example using a HashSet:

Sets

3. Maps

A Map is a key-value pair collection. It allows you to associate values with unique keys. The most common implementation is HashMap. Here’s an example:

Maps

Java’s Built-In APIs

Java provides a rich set of built-in APIs for various tasks. Here are a few commonly used ones:

java.util.Arrays: Contains utility methods for working with arrays.
java.util.String: Provides methods for string manipulation.
java.util.Math: Includes mathematical functions like sqrt, pow, and random.
Remember to import the necessary packages when using these APIs.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

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