Java Programs

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

Basic Java Programs for beginners

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.

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

For most of the examples, we used scanner class to accepts the user inputs and pass to 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 print Even Numbers from 1 to N
  11. Java program to find GCD of a Number
  12. Java Program to find Largest of Two Numbers
  13. Java Program to find largest of Three Numbers
  14. Java Program to find the Average of Three Numbers
  15. Java Program to find the Smallest of Three Numbers
  16. Java program to find LCM of a Number
  17. Java Program to print Multiplication Table
  18. Java program to print Odd Numbers from 1 to N
  19. Java Programs for Odd or Even
  20. Java Programs to find Positive or Negative Number
  21. Java program to find Power of a Number
  22. Java program to calculate Profit or Loss
  23. Java program to print 1 to 100 without using Loops
  24. Java program to find Roots of a Quadratic Equation
  25. Java program to find Square of a Number
  26. Java program to find Square Root of a Number
  27. Java Program to find Square Root of a Number without sqrt
  28. Java program to calculate Simple Interest
  29. Java program to find Sum of Even Numbers
  30. Java program to find Sum of Odd Numbers
  31. Java program to calculate Student Grade
  32. Java program to find Sum of Even and Odd Numbers
  33. Java Programs to find Total Average and Percentage of Five Subjects
  34. Java program to Multiply Two Numbers
  35. Java Program to Multiply Two Floating Point Numbers
  36. Java program to Create a Simple Calculator
  37. Java program to Compute Quotient and Remainder
  38. Java Permutation and Combination Program
  39. Java Random Number Generator
  40. Java Program to Print First 10 Even Natural Numbers
  41. Java Program to Print First 10 Natural Numbers
  42. Java Programs to Print First 10 Natural Numbers in Reverse
  43. Java Programs to Print First 10 Odd Natural Numbers

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 of the advanced concepts that you might face in coding interviews to filter the experienced programmers. They are fibonacci series, armstrong number, palindrome, random number, so on.

  1. Java Programs to Add Two Binary Numbers
  2. check 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 First Digit of a Number
  15. Java program to find First and Last Digit of a Number
  16. Java program to find Generic Root of a Number
  17. Java program to find Last Digit of a Number
  18. Java program to print Natural Numbers from 1 to N
  19. Java program to print Natural Numbers in Reverse Order
  20. Perfect Number Program
  21. Palindrome Program
  22. Java program to check Prime Number or Not
  23. Java program to print Prime Numbers from 1 to N
  24. Java Program to Print first 100 Prime Numbers
  25. Java program to find Sum of Prime Numbers from 1 to N
  26. Java program to Reverse a Number
  27. Java program to check Strong Number
  28. Sum of Digits in a Number
  29. Sum of Natural Numbers from 1 to N
  30. Java Programs to Swap Two Numbers
  31. Java Programs to Get the IP address
  32. Find Arithmetic Sum using Method Overloading

Java Area Programs

The following are the list of java programs to find

  1. Java program to find Area of a Circle
  2. Java program to find Area of a Equilateral Triangle
  3. Java program to find Area of a Isosceles Triangle
  4. Java Programs to find Area of a Parallelogram
  5. Java program to find Area of a Rectangle
  6. Java program to find Area of a Right Angled Triangle
  7. Java program to find Area of a Rhombus
  8. Java program to find Area Of a Triangle
  9. Java program to find Area of a Triangle using base and height
  10. Java Program to find Area Of a Trapezoid
  11. Java Program to find Area of Geometric Figures using Method Overloading
  12. Java program to find Angle of a Triangle
  13. Java program to find Diameter, Circumference, and Area of a Circle
  14. find Perimeter of a Rectangle
  15. find Perimeter of a Rhombus
  16. check Triangle is Equilateral, Isosceles, or Scalene
  17. check Triangle is valid using Angles
  18. check Triangle is valid using Sides

Java Programs on Volume and Surface Area

The following are the Java programs to find the Surface area and Volume of the given data.

  1. Java Program to find Volume and Surface Area of Sphere
  2. Volume and Surface Area of a Cylinder
  3. Volume and Surface Area of Cube
  4. Volume and Surface Area of Cuboid
  5. Volume and Surface Area of Cone

String programs in Java

The below program accepts the given string and work 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. Java program to count Total Occurrence of Character in a String
  12. Java program to find All Occurrences of a Character in a String
  13. Java program to find First Character Occurrence in a String
  14. Java program to find Last Character Occurrence in a String
  15. Java program to Find Maximum Occurring Character in a String
  16. Java program to Find Minimum Occurring Character in a String
  17. Java program to find Frequency of each Character in a String
  18. Java program to check Palindrome String
  19. Java program to print First and Last Character in a String
  20. Java program to remove All Occurrences of a Character in a String
  21. Java program to remove First and Last Character in a String
  22. Java program to remove First Character Occurrence in a String
  23. Java program to remove Last Character Occurrence in a String
  24. Java program To remove all whitespaces from a String
  25. Java program to replace First Character Occurrence in a String
  26. Replace Last Character Occurrence in a String
  27. Reverse Letters in a String
  28. Reverse a String
  29. String Reverse using Recursion
  30. Toggle All Characters in a String
  31. String Comparison
  32. Sort Strings in Alphabetical Order

Java Conversion Programs

The following are list of available conversion programs.

  1. Java Program to Convert Binary To Decimal
  2. Convert Binary To Octal
  3. Convert Celsius To Fahrenheit
  4. Convert Centimeters To Meters and Kilometers
  5. Convert Character to Int
  6. Convert Character to String
  7. Convert Character Array To String
  8. Convert Decimal To Binary
  9. Convert Decimal To Octal
  10. Convert Double to String
  11. Convert Fahrenheit To Celsius
  12. Convert Float to String
  13. Convert Int to Char
  14. Convert Int to Double
  15. Convert Int to Long
  16. Convert Int to String
  17. Convert Kilometers To Miles
  18. Convert Kilometers To Meters Centimeters and Millimeters
  19. Convert Long to Int
  20. Convert Long to String
  21. Convert Miles To Kilometers
  22. Convert Octal To Binary
  23. Convert Octal To Decimal
  24. Convert String to Character
  25. Convert String to Double
  26. Convert String to Float
  27. Convert String to Int
  28. Convert String to Long

Java Programs on Dates

  1. Java Program to Convert String to Date
  2. find Leap Year
  3. Java Program to Print Number of Days in a Month
  4. 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 Programs on Star Pattern

The following are the frequently asked star patter programs in java programming interviews.

  1. Alphabet A
  2. Christmas Tree
  3. Diamond
  4. Downward Triangle
  5. Exponentially Increased Star Pattern
  6. H Star Pattern
  7. Half Diamond
  8. Hollow Diamond Star Pattern
  9. Hollow Diamond Pattern inside a Square
  10. Hollow Inverted Pyramid Star
  11. Hollow Inverted Right Triangle Star Pattern
  12. Hollow Left Pascals Star Triangle
  13. Hollow Mirrored Rhombus Star Pattern
  14. Hollow Pyramid Star Pattern
  15. Hollow Rectangle Star Pattern
  16. Hollow Rhombus Star Pattern
  17. Hollow Right Angled Triangle Star Pattern
  18. Hollow Right Pascals Star Triangle
  19. Hollow Sandglass Star Pattern
  20. Hollow Square Star Pattern
  21. Hollow Square with Diagonals
  22. Inverted Mirrored Right Triangle Star Pattern
  23. Inverted Pyramid Star Pattern
  24. Inverted Right Triangle Star Pattern
  25. Left Arrow Star Pattern
  26. Left Pascals Star Triangle
  27. Mirrored Half Diamond Star Pattern
  28. Mirrored Rhombus Star Pattern
  29. Mirrored Right Triangle Star Pattern
  30. Plus Star Pattern
  31. Pyramid Star Pattern
  32. Rectangle Star Pattern
  33. Reverse Mirrored Right Triangle Star Pattern
  34. Rhombus Star Pattern
  35. Right Angled Triangle Star Pattern
  36. Right Arrow Star Pattern
  37. Right Pascals Star Triangle
  38. Sandglass Star Pattern
  39. Square Star Pattern
  40. V Star Pattern
  41. Inverted V Star Pattern
  42. W Star Pattern
  43. X Star Pattern
  44. 8 Star Pattern

Java Programs for Number Pattern

  1. 1 and 0 in Alternative Rectangle Columns
  2. 1 and 0 in Alternative Rectangle Rows
  3. Box Number Pattern of 1 and 0
  4. Consecutive Numbers Right Triangle Columns
  5. Consecutive Numbers Right Triangle Rows
  6. Diamond Number Pattern
  7. Downward Triangle Mirrored Numbers Pattern
  8. Floyd’s Triangle
  9. Hollow Box Number Pattern
  10. Inverted Right Triangle of Consecutive Numbers
  11. Inverted Right Triangle of Decreasing Order Numbers
  12. Inverted Right Triangle Number Pattern
  13. Inverted Right Triangle Numbers in Reverse
  14. K Shape Number Pattern
  15. Left Pascals Number Triangle
  16. Print Left Arrow Numbers
  17. Print Pascal Triangle
  18. Print Pyramid Numbers Pattern
  19. Right Arrow Number Pattern
  20. Right Pascals Number Triangle
  21. Right Pascals Triangle of Multiplication Numbers
  22. Right Pascals Triangle of Mirrored Numbers
  23. Right Triangle of 1 and 0
  24. Right Triangle Number Pattern
  25. Right Triangle of Numbers in Reverse
  26. Right Triangle of Incremented Numbers
  27. Right Triangle of Mirrored Numbers Pattern
  28. Right Triangle of Numbers in Sine Wave
  29. Right Triangle of Fibonacci Series Numbers
  30. Sandglass Number Pattern
  31. Same Numbers on all Sides of a Square
  32. Same Numbers in Rectangle Rows and Columns
  33. Same Numbers in Square Rows and Columns
  34. Square Number Pattern
  35. Square With Diagonal Numbers Pattern
  36. Square of Left Decrement Numbers Pattern
  37. Square of Left Shift Numbers Pattern
  38. Square of Right Increment Numbers Pattern
  39. Square of Right Decrement Numbers
  40. Square of Numbers in Sine Wave
  41. Simple Number
  42. Triangle Numbers
  43. Triangle of Numbers in Reverse
  44. Triangle of Mirrored Numbers
  45. Inverted Triangle Numbers
  46. Left Shift the Square Pattern of Odd Numbers
  47. Java Programming examples to print V Numbers Pattern

Java Programs for practice on Alphabet Pattern

  1. Diamond Alphabets
  2. Downward Triangle Alphabets
  3. Downward Triangle of Mirrored Alphabets
  4. K Shape Alphabets Pattern
  5. Left Arrow Alphabets Pattern
  6. Pyramid Alphabets Pattern
  7. Right Arrow Alphabets Pattern
  8. Right Pascals Triangle Alphabets
  9. Repeated Character Pattern
  10. Right Triangle Alphabets Pattern
  11. Right Triangle of Alphabets in Reverse
  12. Right Triangle Characters Pattern
  13. Right Triangle of Consecutive Alphabets Pattern
  14. Right Triangle of Consecutive Row Alphabets
  15. Right Triangle of Incremental Alphabets Pattern
  16. Right Triangle of Mirrored Alphabets
  17. Inverted Right Triangle Alphabets
  18. Mirrored Right Triangle Alphabets
  19. Sandglass Alphabets
  20. Square of Right Increment Alphabets
  21. Triangle Alphabets Pattern
  22. Triangle of Alphabets in Reverse
  23. Triangle of Mirrored Alphabets
  24. Java Programming examples to Print Triangle of Same Alphabets
  25. Java Program to Print Inverted Triangle Alphabets

Comments are closed.