Skip to content

batuzihni/java-array-swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Array Element Swapper in Java πŸ”„

This is a simple Java program that swaps two elements in an array based on user input. The user specifies two indices, and the elements at those indices are swapped.

πŸ“ Description

This Java application performs the task of swapping two elements in an array. The user provides two indices, and the program exchanges the elements at those positions. It also ensures that the indices provided are within the bounds of the array to prevent errors.

How to Use:

  1. The program initializes an array with a few names.
  2. The user is prompted to enter two indices (positions) of the array.
  3. The program swaps the elements at those indices.
  4. The updated array is displayed after the swap.

Example:

  • Initial array: ["Alex", "Max", "Charlie", "Bob", "Ada", "Jim"]
  • User enters index 0 and 3.
  • After the swap: ["Bob", "Max", "Charlie", "Alex", "Ada", "Jim"]

βš™οΈ Installation

  1. Clone the repository to your local machine:
    git clone https://github.com/your-username/java-array-swapping.git

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages