50 Java Array Programs (With User Input)
This PDF contains 50 Java array programs written in a simple, college-level style. Each program
uses Scanner for user input and is suitable for Capgemini & other placement exams.
NOTE: • Run one program at a time • Class name used: Main • Input from keyboard
1. Read and Print Array
2. Sum of Array
3. Average of Array
4. Maximum Element
5. Minimum Element
6. Count Even Numbers
7. Count Odd Numbers
8. Reverse Array
9. Copy Array
10. Linear Search
11. Sort Ascending
12. Sort Descending
13. Second Largest
14. Second Smallest
15. Count Positive Numbers
16. Count Negative Numbers
17. Replace Negative with Zero
18. Print Duplicate Elements
19. Remove Duplicates
20. Frequency of Elements
21. Merge Two Arrays
22. Common Elements
23. Union of Arrays
24. Intersection of Arrays
25. Left Rotate
26. Right Rotate
27. Palindrome Array
28. Missing Number
29. Move Zeros
30. Maximum Subarray Sum
31. Check Sorted
32. Reverse using Temp
33. Even → Square
34. Odd → Cube
35. Count Primes
36. Print Primes
37. Sum Even Index
38. Sum Odd Index
39. Insert Element
40. Delete Element
41. Pair with Sum
42. Majority Element
43. Smallest Difference
44. Largest Difference
45. Rotate K Times
46. Check Arrays Equal
47. Count Distinct
48. Leader Elements
49. Replace with Next Greatest
50. Equilibrium Index