Skip to content

Dancan254/Java-Collections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Collections

Collections are a way to group multiple items together. A collection can contain any number of items, and each item can be of a different type. For example, a collection can contain a string, a number, and a boolean. A collection can also contain other collections, allowing for nested structures.

Collections are useful for organizing data in a structured way. For example, you could use a collection to represent a list of items, such as a list of products in a store. Each item in the collection could contain information about a specific product, such as its name, price, and quantity.

Collections are also useful for representing more complex data structures, such as trees or graphs. For example, you could use a collection to represent a tree structure, where each item in the collection represents a node in the tree, and contains information about the node's value and its children.

Arrays and Array utilities from the Java.util.arrays are not part of this framework

List

A list is a collection that contains an ordered sequence of items. Each item in the list is assigned an index, starting from 0. This allows you to access items in the list by their index.

Lists are useful for storing data that needs to be accessed in a specific order. For example, you could use a list to store a list of tasks that need to be completed, and then access each task in the order that it needs to be completed.

Set

A set is a collection that contains a unique set of items. This means that each item in the set is unique, and no two items in the set are the same.

Sets are useful for storing data that needs to be unique. For example, you could use a set to store a list of unique email addresses, ensuring that each email address is only stored once.

Map

A map is a collection that contains a set of key-value pairs. Each key in the map is unique, and is used to access the corresponding value.

Maps are useful for storing data that needs to be accessed by a specific key. For example, you could use a map to store a list of products in a store, where each product is identified by a unique product code.

Queue

A queue is a collection that contains a sequence of items. Items are added to the back of the queue, and removed from the front of the queue. This ensures that items are processed in the order that they were added.

Queues are useful for storing data that needs to be processed in a specific order. For example, you could use a queue to store a list of tasks that need to be completed, and then process each task in the order that it was added to the queue.

Stack

A stack is a collection that contains a sequence of items. Items are added to the top of the stack, and removed from the top of the stack. This ensures that items are processed in a last-in, first-out order.

Stacks are useful for storing data that needs to be processed in a last-in, first-out order. For example, you could use a stack to store a list of web pages that a user has visited, allowing the user to navigate back through the pages in the order that they were visited.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages