Java Programs

Java Programs : This article includes various Java programs covering all the topics such as control statements, strings, arrays, loops, classes, functions, matrices, etc. For all these simple and basic Java programs, we provide multiple examples and the compiled code result.

Java is a high level object oriented programming language that runs on various platforms, including Windows, mac os, Unix, etc. Before going through these Java programming examples, please visit our Tutorial section to learn Java Programming language with examples.

Basic Java Programs for Beginners

We start this section with the hello world program and cover all the programs, ranging from basic to advanced programs, with proper explanation.

For most of the examples, we used the scanner class to accept the user inputs and pass them to the public static void main string args method.

  1. Java Programs to print Hello World
  2. Get Input from User
  3. Java program to print an Integer
  4. Java Program to Read Integer Value from the Standard Input
  5. Java program to add Two Numbers
  6. Java program to add Two Complex Numbers
  7. Java program to find Compound Interest
  8. Java Program to check Number Divisible by 5 and 11
  9. Java Program to find Cube of a Number
  10. Java program to find GCD of a Number
  11. Java Program to find Largest of Two Numbers
  12. Java Program to find largest of Three Numbers
  13. Java Program to find the Average of Three Numbers
  14. Java Program to find the Smallest of Three Numbers
  15. Java program to find LCM of a Number
  16. Java Program to print Multiplication Table
  17. Java Programs for Odd or Even
  18. Java Programs to find Positive or Negative Number
  19. Java program to find Power of a Number
  20. Java program to calculate Profit or Loss
  21. Java program to print 1 to 100 without using Loops
  22. Java program to find Roots of a Quadratic Equation
  23. Java program to find Square of a Number
  24. Java program to find Square Root of a Number
  25. Java Program to find Square Root of a Number without sqrt
  26. Java program to calculate Simple Interest
  27. Java program to calculate Student Grade
  28. Java Programs to find Total Average and Percentage of Five Subjects
  29. Java program to Multiply Two Numbers
  30. Java Program to Multiply Two Floating Point Numbers
  31. Java program to Create a Simple Calculator
  32. Java program to Compute Quotient and Remainder
  33. Java Permutation and Combination Program
  34. Java Random Number Generator

Please refer to the Java program to print Natural Numbers article to understand the programming logic to print the first 10 odd, even, and Natural numbers. You can also find the programs to print even, odd natural numbers from 1 to 100 or 1 to N and their Sum.

Java Programs on Characters

The following are generally asked character programs

  1. Java Program to find ASCII Value of a Character
  2. find ASCII value of all Characters
  3. display Alphabets from a to z
  4. print Alphabets from A to Z
  5. Character is Alphabet or Not
  6. Character is Vowel or Consonant

Advanced Java Programs on Numbers

This section covers some advanced concepts you might face in coding interviews to filter the experienced programmers. They are the Fibonacci series, Armstrong number, palindrome, random numbers, etc.

  1. Java Programs to Add Two Binary Numbers
  2. Armstrong Number
  3. Java Program to Check Peterson Number
  4. Java Program to Check Spy Number
  5. Java Program to Check Sunny Number
  6. Java Program to Check Tech Number
  7. Java program to count Digits in a Number
  8. Electricity Bill Program
  9. Java program to find Factors of a Number
  10. Factorial Program
  11. Fibonacci Series
  12. Java Programs to Generate Random Numbers
  13. Java Programs to Break Integer into Digits
  14. Java program to find the First Digit of a Number
  15. Java program to find the First and Last Digit of a Number
  16. Java program to find the Generic Root of a Number
  17. Java program to find the Last Digit of a Number
  18. Perfect Number Program
  19. Palindrome Program
  20. Java program to check Prime Number or Not
  21. Java program to print Prime Numbers from 1 to N
  22. Java Program to Print first 100 Prime Numbers
  23. Java program to find Sum of Prime Numbers from 1 to N
  24. Java program to Reverse a Number
  25. Java program to check Strong Number
  26. Sum of Digits in a Number
  27. Java Programs to Swap Two Numbers
  28. Java Programs to Get the IP address
  29. Find Arithmetic Sum using Method Overloading

Java Area Programs

The Area examples article shows the list of Java programs to find the area and perimeter of a circle, triangle, trapezoid, rhombus, etc. It also covers the Surface area and Volume of the Sphere, Cylinder, Cube, Cuboid, and Cone.

Java String programs

The below program accepts the given string and works on all the elements or character array in string args.

  1. Tutorial on Java programming language
  2. Java Program to Print Characters in a String
  3. Java program to print ASCII values of String Characters
  4. Java program to concat Strings
  5. Java program to convert Lowercase to Uppercase
  6. Java program to convert Uppercase to Lowercase
  7. Java program to count Total Characters in a String
  8. Java program to count Total Words in a String
  9. Java programs to count Alphabets Digits & Special Characters in a String
  10. Java program to count Vowels and Consonants in a String
  11. The Java program to find All Occurrences of a Character in a String article contains information about finding, replacing, and deleting first, last, maximum, and minimum occurring characters.
  12. Java program to check Palindrome String
  13. Java program To remove all whitespaces from a String
  14. Reverse Letters in a String
  15. Reverse a String
  16. String Reverse using Recursion
  17. Toggle All Characters in a String
  18. String Comparison
  19. Sort Strings in Alphabetical Order

Java Conversion Programs

The Conversion article shows the available list of conversion programs and multiple examples. The common and frequently asked programs are to convert Int to String and String to Integer.

Java Programs on Dates

  1. Leap Year
  2. Java Program to Print Number of Days in a Month
  3. Java Program to Measure Elapsed Time

Array Programs in Java

  1. Java Program to Print Array Elements
  2. perform Arithmetic Operations on Array
  3. copy an Array to another
  4. Count Occurrence of an Element in an Array
  5. Count Even Numbers in an Array
  6. Count Even and Odd Numbers in an Array
  7. Count Odd Numbers in an Array
  8. Count Positive Array Numbers
  9. Count Negative Array Numbers
  10. Count Positive and Negative Numbers in an Array
  11. Count Array Duplicates
  12. Count Frequency of each Element in an Array
  13. Calculate Average of an Array
  14. Java Program to Delete Array Duplicates
  15. Java Program to Increment All Elements of an Array by One
  16. print Largest Array Number
  17. print Largest and Smallest Array Number
  18. Print Negative Array Numbers
  19. Print Positive Array Numbers
  20. Put Positive and Negative Numbers in Separate Array
  21. Second Largest Array Number
  22. Smallest Array Number
  23. Sort Array Elements in Ascending Order
  24. Sort Array Elements in Descending Order
  25. Sum of All Elements in an Array
  26. Sum of Even Numbers in an Array
  27. Sum of Even and Odd Numbers in an Array
  28. Sum of Odd Numbers in an Array
  29. Reverse an Array
  30. Swap Two Array without using Temp Variable
  31. Unique Array Items
  32. Print Kth element in an Array
  33. Find the Number of Elements in an Array

Java Programs on Matrix

  1. Java Program to Print Matrix Items
  2. Perform Arithmetic operations on Matrix
  3. Add Two Matrices
  4. Check Two Matrices are Equal
  5. Calculate Determinant of a Matrix
  6. Check Identity Matrix
  7. Interchange Matrix Diagonals
  8. Print Lower Triangle of a Matrix
  9. Multiply two Matrices
  10. Scalar Matrix Multiplication
  11. Sparse Matrix
  12. Subtract two Matrices
  13. Sum of the Matrix Lower Triangle
  14. Sum of the Matrix Upper Triangle
  15. Sum of Matrix Opposite Diagonal
  16. Sum of Matrix Diagonal
  17. Sum of each Matrix Column
  18. Sum of each Matrix Row
  19. Sum of Matrix Rows and Column
  20. Symmetric Matrix
  21. Transpose Matrix
  22. Upper Triangle of a Matrix
  23. Find the Normal of a Matrix
  24. Find the Trace of a Matrix

Java Programs for Sorting & Searching

  1. Java Bubble Sort on Integers
  2. Java Programming examples to perform Bubble Sort in Descending Order
  3. Java Programming examples to perform Bubble Sort on Strings
  4. Java Programming examples to perform Binary Search
  5. Java Programming examples to perform Linear Search
  6. Java Programming examples to perform Selection Sort

Java Pattern Programs

You can use the For Loops, Do While loops, and While loops to develop any pattern programs in Java. There are many pattern programs, so please refer to the following hyperlinks to see their list.

Comments are closed.