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 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
- List of Area Programs
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
- List of Conversion Programs
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 Programs on Star Pattern
The following are the frequently asked star patter programs in java programming interviews.
- Star Pattern
- Number Patterns
- Alphabet Patterns
- Alphabet A
- Christmas Tree
- Diamond
- Downward Triangle
- Exponentially Increased Star Pattern
- H Star Pattern
- Half Diamond
- Hollow Diamond Star Pattern
- Hollow Diamond Pattern inside a Square
- Hollow Inverted Pyramid Star
- Hollow Inverted Right Triangle Star Pattern
- Hollow Left Pascals Star Triangle
- Hollow Mirrored Rhombus Star Pattern
- Hollow Pyramid Star Pattern
- Hollow Rectangle Star Pattern
- Hollow Rhombus Star Pattern
- Hollow Right Angled Triangle Star Pattern
- Hollow Right Pascals Star Triangle
- Hollow Sandglass Star Pattern
- Hollow Square Star Pattern
- Hollow Square with Diagonals
- Inverted Mirrored Right Triangle Star Pattern
- Inverted Pyramid Star Pattern
- Inverted Right Triangle Star Pattern
- Left Arrow Star Pattern
- Left Pascals Star Triangle
- Mirrored Half Diamond Star Pattern
- Mirrored Rhombus Star Pattern
- Mirrored Right Triangle Star Pattern
- Plus Star Pattern
- Pyramid Star Pattern
- Rectangle Star Pattern
- Reverse Mirrored Right Triangle Star Pattern
- Rhombus Star Pattern
- Right Angled Triangle Star Pattern
- Right Arrow Star Pattern
- Right Pascals Star Triangle
- Sandglass Star Pattern
- Square Star Pattern
- V Star Pattern
- Inverted V Star Pattern
- W Star Pattern
- X Star Pattern
- 8 Star Pattern
Java Programs for Number Pattern
- 1 and 0 in Alternative Rectangle Columns
- 1 and 0 in Alternative Rectangle Rows
- Box Number Pattern of 1 and 0
- Consecutive Numbers Right Triangle Columns
- Consecutive Numbers Right Triangle Rows
- Diamond Number Pattern
- Downward Triangle Mirrored Numbers Pattern
- Floyd’s Triangle
- Hollow Box Number Pattern
- Inverted Right Triangle of Consecutive Numbers
- Inverted Right Triangle of Decreasing Order Numbers
- Inverted Right Triangle Number Pattern
- Inverted Right Triangle Numbers in Reverse
- K Shape Number Pattern
- Left Pascals Number Triangle
- Print Left Arrow Numbers
- Print Pascal Triangle
- Print Pyramid Numbers Pattern
- Right Arrow Number Pattern
- Right Pascals Number Triangle
- Right Pascals Triangle of Multiplication Numbers
- Right Pascals Triangle of Mirrored Numbers
- Right Triangle of 1 and 0
- Right Triangle Number Pattern
- Right Triangle of Numbers in Reverse
- Right Triangle of Incremented Numbers
- Right Triangle of Mirrored Numbers Pattern
- Right Triangle of Numbers in Sine Wave
- Right Triangle of Fibonacci Series Numbers
- Sandglass Number Pattern
- Same Numbers on all Sides of a Square
- Same Numbers in Rectangle Rows and Columns
- Same Numbers in Square Rows and Columns
- Square Number Pattern
- Square With Diagonal Numbers Pattern
- Square of Left Decrement Numbers Pattern
- Square of Left Shift Numbers Pattern
- Square of Right Increment Numbers Pattern
- Square of Right Decrement Numbers
- Square of Numbers in Sine Wave
- Simple Number
- Triangle Numbers
- Triangle of Numbers in Reverse
- Triangle of Mirrored Numbers
- Inverted Triangle Numbers
- Left Shift the Square Pattern of Odd Numbers
- Java Programming examples to print V Numbers Pattern
Java Programs for practice on Alphabet Pattern
- Diamond Alphabets
- Downward Triangle Alphabets
- Downward Triangle of Mirrored Alphabets
- K Shape Alphabets Pattern
- Left Arrow Alphabets Pattern
- Pyramid Alphabets Pattern
- Right Arrow Alphabets Pattern
- Right Pascals Triangle Alphabets
- Repeated Character Pattern
- Right Triangle Alphabets Pattern
- Right Triangle of Alphabets in Reverse
- Right Triangle Characters Pattern
- Right Triangle of Consecutive Alphabets Pattern
- Right Triangle of Consecutive Row Alphabets
- Right Triangle of Incremental Alphabets Pattern
- Right Triangle of Mirrored Alphabets
- Inverted Right Triangle Alphabets
- Mirrored Right Triangle Alphabets
- Sandglass Alphabets
- Square of Right Increment Alphabets
- Triangle Alphabets Pattern
- Triangle of Alphabets in Reverse
- Triangle of Mirrored Alphabets
- Java Programming examples to Print Triangle of Same Alphabets
- Java Program to Print Inverted Triangle Alphabets
Comments are closed.