This repository contains a simple Java program that demonstrates the basic structure of a Java application. The program begins execution from the main method and prints a message to the console.
The program performs the following actions:
- Defines a class named HelloWorld
- Includes the main method, which serves as the entry point of the program
- Uses System.out.println() to display text in the terminal
This program is commonly used as an introduction to Java programming. It helps in understanding:
- How a Java class is created
- How the main method works
- How to print output to the console
Hello, World
This Java program demonstrates how to store numbers in an ArrayList, sort them in ascending order, and display the sorted result. It uses built-in Java utilities to manage and organize data efficiently.
The program performs the following operations:
- Creates an ArrayList to store integer values
- Adds multiple numbers to the list
- Sorts the list using the Collections.sort() method
- Prints each sorted number to the console using a loop
- ArrayList from java.util
- Collections class for sorting
- Enhanced for loop for iteration
This program helps in understanding:
- How to use ArrayList in Java
- How to sort data using Collections.sort()
- How to iterate through a collection and print values
8
12
15
20
33
34
This Java program demonstrates the use of a LinkedList to store and manage string elements. It shows how to add elements at specific positions and how to traverse the list using different looping techniques.
The program performs the following tasks:
- Creates a LinkedList of String values
- Adds elements to the list
- Inserts an element at a specific index
- Displays the list using a for loop
- Displays the list again using an enhanced for-each loop
- LinkedList from java.util
- Adding elements and inserting at a specific index
- Accessing elements using index-based iteration
- Iterating through a collection using for-each loop
This program helps in understanding:
- How LinkedList works in Java
- Different ways to traverse a LinkedList
- How insertion at a specific position affects the list
Welcome to Java Programming
Welcome to Java Programming
This Java program demonstrates the use of the Stack class to store integer elements and remove them using the Last In, First Out (LIFO) principle.
The program performs the following operations:
- Creates a Stack of Integer values
- Pushes elements onto the stack
- Checks whether the stack is empty
- Pops elements from the stack until it becomes empty
- Prints each removed element to the console
- Stack class from java.util
- push() and pop() operations
- LIFO (Last In, First Out) behavior
- while loop for stack traversal
This program helps in understanding:
- How a stack works in Java
- How elements are added and removed from a stack
- How to use isEmpty() to safely pop elements
4
3
2
1
This Java program demonstrates how a Queue stores and manages string elements. The elements are automatically arranged based on their natural alphabetical order.
The program performs the following actions:
- Creates a Queue of String values
- Inserts elements into the queue
- Displays the contents of the queue
- Queue class from java.util
- Queue interface
- add() method for inserting elements
- Natural ordering of String elements
- Automatic sorting mechanism
This program helps in understanding:
- How Queue works internally
- How elements are ordered in a queue
- Basic operations performed on a queue
[Java, Programming]