Java Programs | Java Programming Examples with Output | 200+ List of Simple Java Programming Interview Questions

Exploring java programs from basic to advanced can be done via this ultimate BTech Geeks Java Programming Examples tutorial. An excellent way to learn this most effective java programming language is by practicing all these java programs. The following core java programs for beginners & experienced developers are tested and provided with output for better learnings and practice. Java Programmers who wish to upskill their programming skills should start practicing the best java programs. Here’s the new collection list of basic java programs for beginners and experienced java programmers.

List of 200+ Simple Java Programming Examples for Beginners

Java Basic Programs for Beginners | Basic Core Java Programs for Interview

Java Decision Making and Loop Programming Examples

Java Star Pattern Programs

Java Character Programs

Java Type Conversion Programs

  • Java Program to convert Character to String and Vice-Versa
  • Java Program to convert char type variables to int
  • Java Program to convert int type variables to char
  • Java Program to convert long type variables into int
  • Java Program to convert int type variables to long
  • Java Program to convert boolean variables into string
  • Java Program to convert string type variables into boolean
  • Java Program to convert string type variables into int
  • Java Program to convert int type variables to String
  • Java Program to convert int type variables to double
  • Java Program to convert double type variables to int
  • Java Program to convert string variables to double
  • Java Program to convert double type variables to string
  • Java Program to convert primitive types to objects and vice versa

Java Functions Programs

  • Java Program to Display Prime Numbers Between Intervals Using Function
  • Java Program to Display Armstrong Numbers Between Intervals Using Function
  • Java Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers
  • Java Program to Convert Binary Number to Decimal and vice-versa
  • Java Program to Convert Octal Number to Decimal and vice-versa
  • Java Program to Convert Binary Number to Octal and vice-versa
  • Java Program to Call One Constructor from another
  • Java Program to implement private constructors
  • Java Program to pass lambda expression as a method argument
  • Java Program to pass method call as arguments to another method
  • Java Program to Calculate the Execution Time of Methods

Java Array Programs

  • Java Program to Calculate Average Using Arrays
  • Java Program to Find Largest Element of an Array
  • Java Program to Calculate Standard Deviation
  • Java Program to Add Two Matrix Using Multi-dimensional Arrays
  • Java Program to Multiply to Matrix Using Multi-dimensional Arrays
  • Java Program to Multiply two Matrices by Passing Matrix to a Function
  • Java Program to Find Transpose of a Matrix
  • Java Program to Print an Array
  • Java Program to Concatenate Two Arrays
  • Java Program to Check if An Array Contains a Given Value

Java Class and Object Programs | Object and Class Java Programming Examples

  • Java Program to Calculate Difference Between Two Time Periods
  • Java Program to Determine the class of an object
  • Java Program to Create an enum class
  • Java Program to Print object of a class
  • Java Program to Create custom exception
  • Java Program to Create an Immutable Class
  • Java Program to Create a Class and Object
  • Java Program to Create Abstract Class
  • Java Program to Create Singleton Class
  • Java Program to Create an Interface
  • Java Program to Sow Encapsulation in Class
  • Java Program to Show Inheritance in Class
  • Java Program to Show Abstraction in Class
  • Java Program to Show Data Hiding in Class
  • Java Program to Show Polymorphism in Class
  • Java Program to Show Overloading of Methods in Class
  • Java Program to Show Overriding of Methods in Classes
  • Java Program to Show Use of Super Keyword in Class
  • Java Program to Show Use of This Keyword in Class
  • Java Program to Show Usage of Static keyword in Class
  • Java Program to Show Usage of Access Modifier

Java String Programs

  • Java Program to Convert String to Date
  • Java Program to Convert a Stack Trace to a String
  • Java Program to Compare Strings
  • Java Program to Check if a String is Numeric
  • Java Program to Check if two strings are anagram
  • Java Program to Compute all the permutations of the string
  • Java Program to Create random strings
  • Java Program to Clear the StringBuffer
  • Java Program to Capitalize the first character of each word in a String
  • Java Program to Iterate through each characters of the string.
  • Java Program to Differentiate String == operator and equals() method
  • Java Program to Implement switch statement on strings
  • Java Program to Check if a string contains a substring
  • Java Program to Check if a string is a valid shuffle of two distinct strings
  • Java Program to Get a Character From the Given String
  • Java Program to Replace a Character at a Specific Index
  • Java Program to Reverse a String
  • Java Program to Reverse a String Using Stacks
  • Java Program to Sort a String
  • Java Program to Swapping Pair of Characters
  • Java Program to Check Whether the Given String is Pangram
  • Java Program to Print first letter of each word using regex
  • Java Program to Determine the Unicode Code Point at a given index
  • Java Program to Remove leading zeros
  • Java Program to Compare two strings
  • Java Program to Compare two strings lexicographically
  • Java Program to Print even length words
  • Java Program to Insert a string into another string
  • Java Program to Splitting into a number of sub-strings

Java Collections Programs

  • Java Program to Join Two Lists
  • Java Program to Convert the ArrayList to an array and vice versa
  • Java Program to Convert Map (HashMap) to List
  • Java Program to Convert Array to Set (HashSet) and Vice-Versa
  • Java Program to Sort a Map By Values
  • Java Program to Sort ArrayList of Custom Objects By Property
  • Java Program to Implement LinkedList
  • Java Program to Implement stack data structure
  • Java Program to Implement the queue data structure
  • Java Program to Get the middle element of LinkedList in a single iteration
  • Java Program to Convert the LinkedList into an Array and vice versa
  • Java Program to Convert the ArrayList into a string and vice versa
  • Java Program to Iterate over an ArrayList
  • Java Program to Iterate over a HashMap
  • Java Program to Iterate over a Set
  • Java Program to Merge two lists
  • Java Program to Update value of HashMap using key
  • Java Program to Remove duplicate elements from ArrayList
  • Java Program to Get key from HashMap using the value
  • Java Program to Detect loop in a LinkedList
  • Java Program to Calculate union of two sets
  • Java Program to Calculate the intersection of two sets
  • Java Program to Calculate the difference between two sets
  • Java Program to Check if a set is the subset of another set
  • Java Program to Sort map by keys
  • Java Program to Pass ArrayList as the function argument
  • Java Program to Iterate over ArrayList using Lambda Expression
  • Java Program to Implement Binary Tree Data Structure
  • Java Program to Perform the preorder tree traversal
  • Java Program to Perform the postorder tree traversal
  • Java Program to Perform the inorder tree traversal
  • Java Program to Count number of leaf nodes in a tree
  • Java Program to Implement the graph data structure
  • Java Program to Remove elements from the LinkedList.
  • Java Program to Add elements to a LinkedList
  • Java Program to Access elements from a LinkedList.
  • Java Program to Use Different Types of a Collection
  • Java Program to Print a Collection
  • Java Program to Get the Size of the Collection
  • Java Program to Compare Elements in a Collection
  • Java Program to Shuffle the Elements of a Collection
  • Java Program to Reverse a Collection
  • Java Program to Convert Collection into Array
  • Java Program to Convert Array into Collection
  • Java Program to Replace Elements in a List
  • Java Program to Rotate Elements of a List
  • Java Program to Iterate through Elements of HashMap

Java Algorithms Programs

  • Java Program to Implement Bubble Sort algorithm
  • Java Program to Implement Quick Sort Algorithm
  • Java Program to Implement Merge Sort Algorithm
  • Java Program to Implement Binary Search Algorithm

Java Files Programs

  • Java Program to Get Current Working Directory
  • Java Program to Create String from Contents of a File
  • Java Program to Append Text to an Existing File
  • Java Program to Convert File to byte array and Vice-Versa
  • Java Program to Create Directories
  • Java Program to Rename File
  • Java Program to Get all Files Present in a Directory
  • Java Program to Copy File
  • Java Program to Create File and Write to the File
  • Java Program to Read the Content of a File Line by Line
  • Java Program to Delete File in Java
  • Java Program to Delete Empty and Non-empty Directory
  • Java Program to Get the File Extension
  • Java Program to Get the name of the file from the absolute path
  • Java Program to Get the relative path from two absolute paths
  • Java Program to Count Number of lines present in the file
  • Java Program to Create a temporary file
  • Java Program to Make a File Read-Only
  • Java Program to Compare Paths of Two files
  • Java Program to Copy one file into another file
  • Java Program to Print all the Pattern that Matches Given Pattern From a File
  • Java Program to Append a String in an Existing File
  • Java Program to Read content from one file and writing it into another file
  • Java Program to Read and printing all files from a zip file

Java I/O Stream Programs

  • Java Program to Convert InputStream to String
  • Java Program to Convert OutputStream to String
  • Java Program to Convert a String into the InputStream
  • Java Program to Convert the InputStream into Byte Array
  • Java Program to Load File as InputStream

Java Pattern Printing Programs | Java Example Programs on Special Patterns

  • Java Program to Print Right Triangle Star Pattern
  • Java Program to Print Left Triangle Star Pattern
  • Java Program to Print Pyramid Star Pattern
  • Java Program to Print Reverse Pyramid Star Pattern
  • Java Program to Print Upper Star Triangle Pattern
  • Java Program to Print Mirror Upper Star Triangle Pattern
  • Java Program to Print Downward Triangle Star Pattern
  • Java Program to Print Mirror Lower Star Triangle Pattern
  • Java Program to Print Star Pascal’s Triangle
  • Java Program to Print Diamond Star Pattern
  • Java Program to Print Square Star Pattern
  • Java Program to Print Pyramid Star Pattern
  • Java Program to Print Spiral Pattern of Numbers
  • Java Program to Print Diamond Pattern
  • Java Program to Print the Multiplication Table in a Triangle Form
  • Java Program to Draw the Line, Rectangle, Oval, Text Using the Graphics Method

Java Conversion Programs

  • Java Program For Binary to Octal Conversion
  • Java Program For Octal to Decimal Conversion
  • Java Program For Decimal to Octal Conversion
  • Java Program For Hexadecimal to Decimal Conversion
  • Java Program For Decimal to Hexadecimal Conversion
  • Java Program For Decimal to Binary Conversion
  • Java Program For Binary to Decimal Conversion
  • Java Program For Boolean to String Conversion
  • Java Program For String to Double Conversion
  • Java Program For Double to String Conversion
  • Java Program For String to Long Conversion
  • Java Program For Long to String Conversion
  • Java Program For Int to Char Conversion
  • Java Program For Char to Int Conversion

Java Method Programs

  • Java Program to Show Usage of Main() method
  • Java Program to Show Use of Static and Non-static Methods
  • Java Program to Show Usage of forEach() Method
  • Java Program to Show Usage of toString() Method
  • Java Program to Show Usage of codePointAt() Method
  • Java Program to Show Usage of compare() Method
  • Java Program to Show Usage of equals() Method
  • Java Program to Show Usage of hasNext() and next() Method
  • Thread Lifecycle Methods
    • start() Method
    • run() Method

Java Searching Programs

  • Java Program For Linear Search
  • Java Program For Binary Search
  • Java Program to Recursively Linearly Search an Element in an Array

Java 1-D Array Programs

  • Java Program to Search an Element in an Array
  • Java Program to Find the Largest Element in an Array
  • Java Program to Sort an Array
  • Java Program to Sort the Elements of an Array in Descending Order
  • Java Program to Sort the Elements of an Array in Ascending Order
  • Java Program to Remove Duplicate Elements From an Array
  • Java Program to Merge Two Arrays
  • Java Program to Check if Two Arrays Are Equal or Not
  • Java Program to Remove All Occurrences of an Element in an Array
  • Java Program to Find Common Array Elements
  • Java Program to Copy All the Elements of One Array to Another Array
  • Java Program For Array Rotation

Java 2-D Array Programs

  • Java Program to Print a 2D Array
  • Java Program to Add Two Matrices
  • Java Program to Sort the 2D Array Across Columns
  • Java Program to Check Whether Two Matrices Are Equal or Not
  • Java Program to Find the Determinant
  • Java Program to Find the Normal and Trace
  • Java Program to Print Boundary Elements of a Matrix
  • Java Program to Rotate Matrix Elements
  • Java Program to Compute the Sum of Diagonals of a Matrix
  • Java Program to Interchange Elements of First and Last in a Matrix Across Rows
  • Java Program to Interchange Elements of First and Last in a Matrix Across Columns

Java List Programs

  • Java Program to Initializing a List
  • Java Program to Find a Sublist in a List
  • Java Program to Get Minimum and Maximum From a List
  • Java Program to Split a list into Two Halves
  • Java Program to Remove a Sublist from a List
  • Java Program to Remove Duplicates from an Array List
  • Java Program to Remove Null from a List container
  • Java Program to Sort Array list in an Ascending Order
  • Java Program to Get First and Last Elements from an Array List
  • Java Program to Convert a List of String to Comma Separated String
  • Java Program to Add Element at First and Last Position of a Linked list
  • Java Program to Find Common Elements in Two ArrayList
  • Java Program to Remove Repeated Element From An ArrayList

Java Date and Time Programs

  • Java Program to Format time in AM-PM format
  • Java Program to Display Dates of Calender Year in Different Format
  • Java Program to Display current date and time
  • Java Program to Display time in different country’s format
  • Java Program to Convert the local Time to GMT

Java Directory Programs

  • Java Program to Traverse in a directory
  • Java Program to Get the size of a directory
  • Java Program to Delete a directory
  • Java Program to Create directories recursively
  • Java Program to Search for a file in a directory
  • Java Program to Find the current working directory
  • Java Program to Display all the directories in a directory

Java Exceptions and Errors Programs

  • Java Program to Show Runtime exceptions
  • Java Program to Show Types of errors
  • Java Program to Handle the Exception Hierarchies
  • Java Program to Handle the Exception Methods
  • Java program to Handle the Checked exceptions
  • Java Program to Handle the Unchecked Exceptions
  • Java Program to Handle Divide By Zero and Multiple Exceptions
  • Java Program to Show Unreachable Code Error
  • Java Program to Show Thread interface and memory consistency errors

Java Multithreading Programs

  • Java Program to Check the Thread Status
  • Java Program to Suspend a Thread
  • Java Program to Join Threads
  • Java Program to Show Daemon Thread

Java Examples on Mathematical Calculations

Java Simple Programs on Special Numbers

  • Java Program to Print Armstrong Number from 1 to 1000
  • Java Program to Check if a Given Number is Perfect Number
  • Java Program to Check If a Given Number is Armstrong Number
  • Java Program to Check if a Given Number is Prime Number
  • Java Program to Find Sum of Natural Numbers Using While Loop
  • Java Program to Calculate the Sum, Multiplication, Division and Subtraction of Two Numbers
  • Java Program to Print the Next 20 Leap Years
  • Java Program to Print the First Twenty Perfect Squares
  • Java Program to Input a String with at least One Number, Print the Square of all the Numbers in a String

Java Programming Examples on Fibonacci and Complex Numbers

  • Java Program to Display Fibonacci Series
  • Java Program to Print Fibonacci Series in Different Ways
  • Java Program to Generate Fibonacci Numbers
  • Java Program to Compute List of First 100 Fibonacci Numbers
  • Java Program to Add two Complex Numbers
  • Java Program to Add Two Complex Numbers by Passing Class to a Function

Java Examples on Recursion

  • Java Program to Find Factorial Value With Using Recursion
  • Java Program to Find if a Number is Prime or Not Using Recursion
  • Java Program to Print First N Natural Numbers Using Recursion
  • Java Program to Find Factorial Value Without Using Recursion
  • Java Program to Convert a Number Decimal System to Binary System Using Recursion
  • Java Program to Find the Sum of Natural Numbers using Recursion
  • Java Program to Find G.C.D Using Recursion
  • Java Program to Reverse a Sentence Using Recursion
  • Java Program to calculate the power using recursion
  • Java Program to Convert Binary Code of a Number into its Equivalent Gray’s Code Without Using Recursion
  • Java Program to Convert Binary Code of a Number into its Equivalent Gray’s Code Using Recursion

Java Data Types Programming Examples

  • Java Program to Check Whether an Alphabet is Vowel or Consonant
  • Java Program to Check if given Alphabets are Uppercase or Lowercase or Digits
  • Java Program to Illustrate Use of Binary Literals
  • Java Program to Use Underscores in Numeric Literal
  • Java Program to Illustrate the Usage of Decimal Integer, Octal Integer, HexaDecimal, Floating, Character Literals
  • Java Program to Store Escape Sequence and Unicode Characters Using Character Literals
  • Java Program to Perform Binary Addition of Strings

Java Special Programs with Outputs

  • Java Program to Print a Semicolon without Using a Semicolon Anywhere in the Code
  • Java Program to Print any Statement without Using Semicolon
  • Java Program to Accept the Height of a Person & Categorize as Taller, Dwarf & Average
  • Java Program to Generate a DOT Representation of a Graph
  • Java Program to Automatically Generate Essays for You

Java Examples on Delegation Event Model

  • Java Program to Handle MouseEvent
  • Java Program to Handle KeyBoardEvent

Java Program on Handling Check Boxes

  • Java Program to Get and Set State and Get Label of a Check Box

Java Programming Examples on Handling a TextField

  • Java Program to Create 2 Labels and Text Fields for Entering Name and Secured Password
  • Java Program to Display Text in the Frame by Overriding PaintComponent() Method of JPanel Class
  • Java Program to Display Some Text in the Frame with the Help of a Label
  • Java Program to Create a Text Area and Display the Mouse Event When the Button on the Mouse is Clicked, When the Mouse is Moved etc is Done by the User
  • Java Program to Create Some Text Fields and Text Areas to Demonstrate Features
  • Java Program to Trap the Key Code and Key Name Typed by the User on the KeyBoard and Display them in a Text Area
  • Java Program to Trap a Key Which is Pressed on the KeyBoard and Display its Name in the Text Area. In this Program, We Consider Some Keys Only for Demonstration Purpose

Java Programs on Menu Bars and Menus

  • Java Program to Create a Menu with Several Menu Items
  • Java Program to Create a Menu and Handle the File Open Event for the User
  • Java Program to Perform Menu Driven Arithmetic Operations Using Switch Case
  • Java Program to Create a Choice Menu to Select an Item and Display it in the Frame

Java Example Programs on Applet Class

  • Java Program to Create a Basic Applet
  • Java Program to Create a Banner Using Applet
  • Java Program to Display Clock Using Applet
  • Java Program to Create and Fill Shapes using Applet
  • Java Program to Goto a Link using Applet
  • Java Program to Create an Event Listener in Applet
  • Java Program to Display Image Using Applet
  • Java Program to Open a Link in a New window using Applet
  • Java Program to Play Sound Using Applet
  • Java Program to Perform Read and Write Operations for a File using Applet
  • Java Program to Use Swing Applet in JAVA
  • Java Program to Demonstrate a Basic Calculator using Applet
  • Java Program to Display Human Face using Applet
  • Java Program to Load and Display an Image Using Applet
  • Java Program to Find Square of a Given Number Using Applet
  • Java Program to Change the Background Colour of Applet by Clicking on Control Button

Advanced Java Programs with Output

  • Java Program to Get Current Date/TIme
  • Java Program to Convert Milliseconds to Minutes and Seconds
  • Java Program to Add Two Dates
  • Java Program to Convert Byte Array to Hexadecimal
  • Java Program to Lookup enum by String value
  • Java Program to Calculate simple interest and compound interest
  • Java Program to Implement multiple inheritance
  • Java Program to Determine the name and version of the operating system
  • Java Program to Check if two of three boolean variables are true
  • Java Program to Iterate over enum
  • Java Program to Check the birthday and print Happy Birthday message
  • Java Program to Access private members of a class

More Java Programs

  • Java Program to Convert Linked list to an Array
  • Java Program to Convert Vector to a List
  • Java Program to Convert String to a List of Characters
  • Java Program to Convert Iterator to a List
  • Java Program to Convert List to a Map
  • Java Program to Convert List to a Stream
  • Java Program to Convert List to Set
  • Java Program to Convert Set of String to Array of String
  • Java Program to Convert String to Object
  • Java Program to Convert string value to byte value

10 Simple Java Example Programs for Beginners & Experienced Programmers

The following 10 simple java programming examples help beginners and expert programmers learn and practice the short logic of the program for quick usage and upskill your knowledge. Let’s check these basic yet most commonly asked java programs in interviews:

1. ‘Hello World’ Java Program:

One of the most important programs to learn by all developers is an introduction program to java by printing “Hello World” words. Also, check more details about Hello Word Program using Java from here.

Java Program to Print Hello World

2. Prime Number Program in Java:

Out of this plenty of basic java programs list, the most commonly asked programming example in interviews or examinations is Prime Number Java Program. Here is the simple & one-line code for the prime number program. Want to learn more variations about Java Program to Check if a Given Number is Prime Number? Make use of the link provided here.

Prime Number Program in Java

3. Fibonacci Series in Java:

By using the following simple code, you can easily grasp the logic behind the Fibonacci series. If you really excited to learn the various methods like using recursion and without recursion check out this Java Program to Display Fibonacci Series

Fibonacci Series Program in Java

4. Factorial Using Java:

Here, we have given a simple code for a factorial java programming example. If you want to explore more about it then go for this Java Program to Find Factorial of a Number

Java Program for Finding Factorial of a Number

5. Decimal to Binary Conversion in Java:

Check out this shortcode to convert the decimal from binary and practice it regularly for quick usage in the required time of programming. In case, are you a newbie to java conversion programming examples? then view this Java Program for Decimal to Binary Conversion.

Java Program for Decimal to Binary Conversion

6. Matrix Transpose Java Code:

Are you searching for the one-line code to find the transpose of a matrix? then look at the below code. If you need to learn the same program in a detailed manner then click on this Java Program to Find a Transpose of a Matrix.

Java Program to Find Transpose of a Matrix

7. Armstrong Number in Java:

Need a simple program to check whether the given number is Armstrong or not? then make use of the following code for quick reference. For perfect programming in java, practicing the basic Java Program on Check Armstrong Number.

Java Program to Check Armstrong Number

8. Palindrome Number using Java:

This simple line of code is helpful for checking the given number is palindrome or not. If required to learn more about the logic behind it then tap on this Java Program to Check Palindrome.

Java Program to Check Palindrome String

Java Program to Check Palindrome Number

9. String Comparison in Java:

The code for the Java program to compare strings is prevailing here in a short form. If you want to practice more logic on string comparison like Java Program to compare two strings check out the given link.

Java Program to Compare Strings

10. Sorting an Array Using Java:

The best and effective way to understand the array sorting logic is by practicing with the given code. Also, you can check out the different methods by using this link ie., Java Program to Sort an Array.

Java Program to Sort an Array in Ascending Order

Final Words

Hoping that our collection of basic and simple java programs for beginners and experienced programmers helped everyone a lot in learning the java programming language faster. If want to suggest more core java programming examples with output from basic to advanced level, then reach out to us by commenting below and our expert developers will look into them. Click the Ctrl+D shortcut and bookmark our website BTechgeeks.com for getting assistance on any programming languages like C++, Python, etc.