Master fundamental Java concepts with these beginner-friendly programs
A program to find the largest element in an array.
Write a program to find the largest element in an array.
{5, 12, 3, 7, 20}
Largest element: 20
A program to find the smallest element in an array.
Write a program to find the smallest element in an array.
{8, 2, 15, 1, 10}
Smallest element: 1
A program to find the sum of all elements in an array.
Write a program to find the sum of all elements in an array.
{4, 6, 8, 2, 5}
Sum: 25
A program to reverse an array.
Write a program to reverse an array.
{1, 2, 3, 4, 5}
Reversed array: {5, 4, 3, 2, 1}
A program to count the number of even and odd numbers in an array.
Write a program to count the number of even and odd numbers in an array.
{10, 3, 8, 7, 6, 2}
Even count: 4
Odd count: 2
A program to find the second largest element in an array.
Write a program to find the second largest element in an array.
{12, 45, 67, 23, 89, 55}
Second largest element: 67
A program to sort an array in ascending order.
Write a program to sort an array in ascending order.
{5, 2, 9, 1, 6}
Sorted array: {1, 2, 5, 6, 9}
A program to find duplicate elements in an array.
Write a program to find duplicate elements in an array.
{3, 6, 8, 3, 2, 6, 9}
Duplicate elements: 3, 6
A program to merge two arrays into one.
Write a program to merge two arrays into one.
{1, 3, 5} and {2, 4, 6}
Merged array: {1, 3, 5, 2, 4, 6}
A program to left rotate an array by one position.
Write a program to left rotate an array by one position.
{10, 20, 30, 40, 50}
Rotated array: {20, 30, 40, 50, 10}