Skip to content

TessaMJ/Programs

Repository files navigation

Hello World Java Program

Description

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.

Program Overview

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

Purpose

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

Output

Hello, World

Java ArrayList Sorting Program

Description

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.

Program Overview

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

Key Concepts Used

  • ArrayList from java.util
  • Collections class for sorting
  • Enhanced for loop for iteration

Purpose

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

Output

8
12
15
20
33
34

Java LinkedList Program

Description

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.

Program Overview

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

Key Concepts Used

  • 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

Purpose

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

Output

Welcome to Java Programming
Welcome to Java Programming

Java Stack Program

Description

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.

Program Overview

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

Key Concepts Used

  • Stack class from java.util
  • push() and pop() operations
  • LIFO (Last In, First Out) behavior
  • while loop for stack traversal

Purpose

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

Output

4
3
2
1

Java Queue Program

Description

This Java program demonstrates how a Queue stores and manages string elements. The elements are automatically arranged based on their natural alphabetical order.

Program Overview

The program performs the following actions:

  • Creates a Queue of String values
  • Inserts elements into the queue
  • Displays the contents of the queue

Key Concepts Used

  • Queue class from java.util
  • Queue interface
  • add() method for inserting elements
  • Natural ordering of String elements
  • Automatic sorting mechanism

Purpose

This program helps in understanding:

  • How Queue works internally
  • How elements are ordered in a queue
  • Basic operations performed on a queue

Output

[Java, Programming]

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages