250+ Java program examples with output | Java programming exercises


To learn any programming language you have to practice the programs, this is one of the best and faster way to learn programming language.


This webpage contains java programs on various java topics such as Java string programs, control statements, Java Array Programs, Java loops programs, functions, arrays, etc. All the following java programs are tested and provided with the output.


List of JAVA Programs →


JAVA Language Basic programs with examples

  1. Write a Java program to print 'Hello World!' on screen
  2. Write a Java program to print the sum of two numbers
  3. Write a Java program that takes two numbers and display the product of two numbers
  4. Write a Java program to print the sum, multiply, subtract, divide and remainder of two numbers
  5. Write a Java program that takes five numbers as input to calculate and print the average of the numbers
  6. Write a Java program to swap two variables
  7. Write a Java program to convert a decimal number to binary numbers
  8. Write a Java program to convert a binary number to decimal number
  9. Write a Java program to check whether Java is installed on your computer or not
  10. Write a Java program and compute the sum of the digits of an integer
  11. Write a Java program to compare two numbers
  12. Write a Java program to count the letters, spaces, numbers and other characters of an input string
  13. Write a Java program to print the ascii value of a given character
  14. Write a Java program that accepts an integer (n) and computes the value of n+nn+nnn
  15. Write a Java program to display the system time
  16. Write a Java program to print the odd numbers from 1 to 20
  17. Write a Java program to print the even numbers from 1 to 20
  18. Write a Java program to convert a string to an integer
  19. Write a Java program to convert seconds to hour, minute and seconds
  20. Write a Java program to compute the sum of the first 100 prime numbers
  21. Write a Java program to swap the first and last elements of an array and create a new array
  22. Write a Java program to count the number of even and odd elements in a given array
  23. Write a Java program to compute the square root of an given integer
  24. Write a Java program to check if a positive number is a palindrome or not
  25. Write a Java program to add two numbers without using any arithmetic operators
  26. Write a Java program to add all the digits of a given positive integer

List of Simple Formula Based Java Programs

  1. Java program to find area of circle
  2. Java Program to find area of rectangle
  3. Java Program to find area of triangle
  4. Java Program to find area of equilateral triangle
  5. Java Program to find area of rhombus
  6. Java Program to find area of parallelogram
  7. Java Program to find area of Prism
  8. Java Program to find volume of sphere
  9. Java Program to find volume of cylinder
  10. Java Program to find volume of cuboid
  11. Java Program to find volume of cone
  12. Java program to find surface area of cuboid
  13. Java program to find surface area of cylinder
  14. Java program to find surface area of cube
  15. Java program to calculate average marks
  16. Java program to check vowel or consonant
  17. Java program to sum of N numbers
  18. Java program to find factorial of any number
  19. Java Program to calculate electricity bill
  20. Java Program To Calculate CGPA Percentage
  21. Java Program to calculate compound interest
  22. Java Program To Calculate Batting Average
  23. Java Pogram to Calculate Commission Percentage
  24. Java Pogram To Find Distance Between Two Points
  25. Java Program To Calculate Power Of Number

List of all conditional programs in Java language

  1. Write a Java program to take three numbers from the user and print the greatest number
  2. Write a Java program to find the number of days in a month
  3. Write a Java program to test a number is positive or negative
  4. Write a Java Program to accept number of week's day (1-7) and print name of the day
  5. Write a Java program that takes a year from user and print whether that year is a leap year or not
  6. Write a Java program to input 5 numbers from keyboard and find their sum and average
  7. Write a program in Java to display the first 5 natural numbers
  8. Write a java program to check vowel or consonant
  9. Write a Java program to display the cube of the number upto given an integer
  10. Write a Java program to display the n terms of odd natural number and their sum
  11. Write a Java program to display the multiplication table of a given integer
  12. Write a Java program that reads an integer and check whether it is negative, zero, or positive
  13. Write a Java program that reads an positive integer and count the number of digits
  14. Write a Java program that accepts three numbers and check All numbers are equal or not
  15. Write a java program that accepts three numbers from the user and check if numbers are in "increasing" or "decreasing" order.
  16. Write a Java program that determines a student’s grade
  17. Write a Java program to create a simple calculator

List of all string programs in java with examples

  1. Write a Java program to concatenate two string
  2. Write a Java program to convert all characters in a string to lowercase
  3. Write a Java program to convert all characters in a string to uppercase
  4. Write a Java program to trim a string(remove whitespaces)
  5. Write a Java program to get a substring of a given string between two specified positions
  6. Write a Java program to replace all the 'd' characters with 'f' characters
  7. Write a java program to get the length of a given string
  8. Write a java program to print current date and time in the specified format
  9. Write a Java program to get the character at the given index within the String
  10. Write a java program to remove a particular character from a string
  11. Write a java program to reverse a String
  12. Write a java program to remove html tags from a string
  13. Write a java program to count total number of lines from a string

List of Array Programs in Java with Examples

  1. Write a Java program to sum values of an array
  2. Write a Java program to find the index of an array element
  3. Write a Java program to calculate the average value of array elements
  4. Write a Java program to test if an array contains a specific value
  5. Write a Java program to find the maximum and minimum value of an array
  6. Write a Java program to insert an element (specific position) into an array
  7. Write a Java program to reverse an array of integer values
  8. Write a Java program to find the common elements between two arrays
  9. Write a Java program to find the duplicate values of an array of integer values
  10. Write a Java program to convert an array to ArrayList
  11. Write a Java program to add two matrices of the same size
  12. Write a Java program to find second largest number from the array
  13. Write a Java program to find second lowest number from the array
  14. Write a Java program to find the number of even and odd integers in a given array of integers
  15. Write a Java program to get the difference between the largest and smallest values in an array of integers
  16. Write a Java program to segregate all 0s on left side and all 1s on right side of a given array of 0s and 1s
  17. Write a Java program to cyclically rotate a given array clockwise by one
  18. java program to print all unique element in an array
  19. Write a Java Program to Sort the Array in an Ascending Order
  20. Write a Java Program to Sort the Array in an Descending Order
  21. Write a Java Program to Sort Names in an Alphabetical Order
  22. Write a Java Program to Display Transpose Matrix
  23. Write a Java Program to Search Key Elements in an Array
  24. Write a Java Program to Accept the Marks of a Student and find Total Marks and Percentage

List of Loop programs in Java with an examples

  1. Write a java program to print numbers from 1 to 10 using loop
  2. Write a java program to calculate the sum of first 10 natural number using loop
  3. Write a Java program to print multiplication table of given number
  4. Write a Java program to find the factorial value of any number entered through the keyboard
  5. Write a Java program that prompts the user to input an integer and then outputs the number with the digits reversed order
  6. Write a Java program that reads a set of integers, and then prints the sum of the even and odd integers using loop
  7. Write a Java program to check whether the number is a prime number or not
  8. Write a Java program to calculate HCF of Two given numbers using loop
  9. Write a Java program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros
  10. Write a Java program to enter the numbers till the user wants and at the end the program should display the largest and smallest numbers entered
  11. Write a Java program to print out all Armstrong numbers between 1 to 600 using loop
  12. Write a java program to count total number of notes in entered amount using loop
  13. Write a Java program to print Fibonacci series of n terms where n is input by user using loop
  14. Write a java program to calculate the sum of following series where n is input by user

List of Method/Function programming exercises in Java

  1. Write a Java method to compute the average of three numbers
  2. Write a Java method to find the smallest number among three numbers
  3. Write a Java method to count all words in a string
  4. Write a Java method to count all vowels in a string
  5. Write a Java method to compute the sum of the digits in an integer
  6. Write a Java method to check whether an year entered by the user is a leap year or not
  7. Write a Java method to calculate the area of a triangle
  8. Write a Java method to find the area of a pentagon
  9. Write a Java method to find number is even number or not
  10. Write a Java method to check numbers is palindrome number or not
  11. Write a Java method to displays prime numbers between 1 to 20
  12. Write a Java method to find GCD and LCM of Two Numbers
  13. Write a Java method to find factorial using recursion in java

All Collection programs in Java with examples

  1. Write a Java program to create a new array list, add some elements (string) and print out the collection
  2. Write a Java program to insert an element into the array list at the first position
  3. Write a Java program to remove the third element from a array list
  4. Write a Java program to sort a given array list
  5. Write a Java program to shuffle elements in a array list
  6. Write a Java program to increase the size of an array list
  7. Write a Java program to reverse elements in a array list
  8. Write a Java program to compare two array lists
  9. Write a Java program to swap two elements in an array list
  10. Write a Java program to join two array lists
  11. Write a Java program to empty an array list

List of Math Exercises Programs in java With an Examples

  1. Write a Java program to reverse an integer number
  2. Write a Java program to round a float number to specified decimals
  3. Write a Java program to test if a double number is an integer
  4. Write a Java program to round up the result of integer division
  5. Write a Java program to convert Roman number to an integer number
  6. Write a Java program to convert a float value to absolute value
  7. Write a Java program to accept a float value of number and return a rounded float value

Number pattern programs in Java language


Star Pattern in java Programming language


All Java Alphabet programs with examples


     

21 June 2020 |2200 | Written By: Rohit Mhatre






Related Topics





Popular Posts