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.
- Java Programs to print Hello World
- Get Input from User
- Java program to print an Integer
- Java Program to Read Integer Value from the Standard Input
- Java program to add Two Numbers
- Java program to add Two Complex Numbers
- Java program to find Compound Interest
- Java Program to check Number Divisible by 5 and 11
- Java Program to find Cube of a Number
- Java program to print Even Numbers from 1 to N
- Java program to find GCD of a Number
- Java Program to find Largest of Two Numbers
- Java Program to find largest of Three Numbers
- Java Program to find the Average of Three Numbers
- Java Program to find the Smallest of Three Numbers
- Java program to find LCM of a Number
- Java Program to print Multiplication Table
- Java program to print Odd Numbers from 1 to N
- Java Programs for Odd or Even
- Java Programs to find Positive or Negative Number
- Java program to find Power of a Number
- Java program to calculate Profit or Loss
- Java program to print 1 to 100 without using Loops
- Java program to find Roots of a Quadratic Equation
- Java program to find Square of a Number
- Java program to find Square Root of a Number
- Java Program to find Square Root of a Number without sqrt
- Java program to calculate Simple Interest
- Java program to find Sum of Even Numbers
- Java program to find Sum of Odd Numbers
- Java program to calculate Student Grade
- Java program to find Sum of Even and Odd Numbers
- Java Programs to find Total Average and Percentage of Five Subjects
- Java program to Multiply Two Numbers
- Java Program to Multiply Two Floating Point Numbers
- Java program to Create a Simple Calculator
- Java program to Compute Quotient and Remainder
- Java Permutation and Combination Program
- Java Random Number Generator
- Java Program to Print First 10 Even Natural Numbers
- Java Program to Print First 10 Natural Numbers
- Java Programs to Print First 10 Natural Numbers in Reverse
- Java Programs to Print First 10 Odd Natural Numbers
Java Programs on Characters
The following are generally asked character programs
- Java Program to find ASCII Value of a Character
- find ASCII value of all Characters
- display Alphabets from a to z
- print Alphabets from A to Z
- Character is Alphabet or Not
- 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.
- Java Programs to Add Two Binary Numbers
- check Armstrong Number
- Java Program to Check Peterson Number
- Java Program to Check Spy Number
- Java Program to Check Sunny Number
- Java Program to Check Tech Number
- Java program to count Digits in a Number
- Electricity Bill Program
- Java program to find Factors of a Number
- Factorial Program
- Fibonacci Series
- Java Programs to Generate Random Numbers
- Java Programs to Break Integer into Digits
- Java program to find First Digit of a Number
- Java program to find First and Last Digit of a Number
- Java program to find Generic Root of a Number
- Java program to find Last Digit of a Number
- Java program to print Natural Numbers from 1 to N
- Java program to print Natural Numbers in Reverse Order
- Perfect Number Program
- Palindrome Program
- Java program to check Prime Number or Not
- Java program to print Prime Numbers from 1 to N
- Java Program to Print first 100 Prime Numbers
- Java program to find Sum of Prime Numbers from 1 to N
- Java program to Reverse a Number
- Java program to check Strong Number
- Sum of Digits in a Number
- Sum of Natural Numbers from 1 to N
- Java Programs to Swap Two Numbers
- Java Programs to Get the IP address
- Find Arithmetic Sum using Method Overloading
Java Area Programs
The following are the list of java programs to find
- Java program to find Area of a Circle
- Java program to find Area of a Equilateral Triangle
- Java program to find Area of a Isosceles Triangle
- Java Programs to find Area of a Parallelogram
- Java program to find Area of a Rectangle
- Java program to find Area of a Right Angled Triangle
- Java program to find Area of a Rhombus
- Java program to find Area Of a Triangle
- Java program to find Area of a Triangle using base and height
- Java Program to find Area Of a Trapezoid
- Java Program to find Area of Geometric Figures using Method Overloading
- Java program to find Angle of a Triangle
- Java program to find Diameter, Circumference, and Area of a Circle
- find Perimeter of a Rectangle
- find Perimeter of a Rhombus
- check Triangle is Equilateral, Isosceles, or Scalene
- check Triangle is valid using Angles
- 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.
- Java Program to find Volume and Surface Area of Sphere
- Volume and Surface Area of a Cylinder
- Volume and Surface Area of Cube
- Volume and Surface Area of Cuboid
- 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.
- Tutorial on Java programming language
- Java Program to Print Characters in a String
- Java program to print ASCII values of String Characters
- Java program to concat Strings
- Java program to convert Lowercase to Uppercase
- Java program to convert Uppercase to Lowercase
- Java program to count Total Characters in a String
- Java program to count Total Words in a String
- Java programs to count Alphabets Digits & Special Characters in a String
- Java program to count Vowels and Consonants in a String
- Java program to count Total Occurrence of Character in a String
- Java program to find All Occurrences of a Character in a String
- Java program to find First Character Occurrence in a String
- Java program to find Last Character Occurrence in a String
- Java program to Find Maximum Occurring Character in a String
- Java program to Find Minimum Occurring Character in a String
- Java program to find Frequency of each Character in a String
- Java program to check Palindrome String
- Java program to print First and Last Character in a String
- Java program to remove All Occurrences of a Character in a String
- Java program to remove First and Last Character in a String
- Java program to remove First Character Occurrence in a String
- Java program to remove Last Character Occurrence in a String
- Java program To remove all whitespaces from a String
- Java program to replace First Character Occurrence in a String
- Replace Last Character Occurrence in a String
- Reverse Letters in a String
- Reverse a String
- String Reverse using Recursion
- Toggle All Characters in a String
- String Comparison
- Sort Strings in Alphabetical Order
Java Conversion Programs
The following are list of available conversion programs.
- Java Program to Convert Binary To Decimal
- Convert Binary To Octal
- Convert Celsius To Fahrenheit
- Convert Centimeters To Meters and Kilometers
- Convert Character to Int
- Convert Character to String
- Convert Character Array To String
- Convert Decimal To Binary
- Convert Decimal To Octal
- Convert Double to String
- Convert Fahrenheit To Celsius
- Convert Float to String
- Convert Int to Char
- Convert Int to Double
- Convert Int to Long
- Convert Int to String
- Convert Kilometers To Miles
- Convert Kilometers To Meters Centimeters and Millimeters
- Convert Long to Int
- Convert Long to String
- Convert Miles To Kilometers
- Convert Octal To Binary
- Convert Octal To Decimal
- Convert String to Character
- Convert String to Double
- Convert String to Float
- Convert String to Int
- Convert String to Long
Java Programs on Dates
- Java Program to Convert String to Date
- find Leap Year
- Java Program to Print Number of Days in a Month
- Java Program to Measure Elapsed Time
Array Programs in Java
- Java Program to Print Array Elements
- perform Arithmetic Operations on Array
- copy an Array to another
- Count Occurrence of an Element in an Array
- Count Even Numbers in an Array
- Count Even and Odd Numbers in an Array
- Count Odd Numbers in an Array
- Count Positive Array Numbers
- Count Negative Array Numbers
- Count Positive and Negative Numbers in an Array
- Count Array Duplicates
- Count Frequency of each Element in an Array
- Calculate Average of an Array
- Java Program to Delete Array Duplicates
- Java Program to Increment All Elements of an Array by One
- print Largest Array Number
- print Largest and Smallest Array Number
- Print Negative Array Numbers
- Print Positive Array Numbers
- Put Positive and Negative Numbers in Separate Array
- Second Largest Array Number
- Smallest Array Number
- Sort Array Elements in Ascending Order
- Sort Array Elements in Descending Order
- Sum of All Elements in an Array
- Sum of Even Numbers in an Array
- Sum of Even and Odd Numbers in an Array
- Sum of Odd Numbers in an Array
- Reverse an Array
- Swap Two Array without using Temp Variable
- Unique Array Items
- Print Kth element in an Array
- Find the Number of Elements in an Array
Java Programs on Matrix
- Java Program to Print Matrix Items
- Perform Arithmetic operations on Matrix
- Add Two Matrices
- Check Two Matrices are Equal
- Calculate Determinant of a Matrix
- Check Identity Matrix
- Interchange Matrix Diagonals
- Print Lower Triangle of a Matrix
- Multiply two Matrices
- Scalar Matrix Multiplication
- Sparse Matrix
- Subtract two Matrices
- Sum of the Matrix Lower Triangle
- Sum of the Matrix Upper Triangle
- Sum of Matrix Opposite Diagonal
- Sum of Matrix Diagonal
- Sum of each Matrix Column
- Sum of each Matrix Row
- Sum of Matrix Rows and Column
- Symmetric Matrix
- Transpose Matrix
- Upper Triangle of a Matrix
- Find the Normal of a Matrix
- Find the Trace of a Matrix
Java Programs for Sorting & Searching
- Java Bubble Sort on Integers
- Java Programming examples to perform Bubble Sort in Descending Order
- Java Programming examples to perform Bubble Sort on Strings
- Java Programming examples to perform Binary Search
- Java Programming examples to perform Linear Search
- 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.