Basic Programs
First programs, constructors, methods and simple class examples.
My First Java Example in Java
My First explained in Java, with a complete example program, its sample output, and a clear code walkthrough.
Constructor Example in Java
A constructor in a class is a special type of method called to create an object, It has the same name as that of the Class.
Parametrized Method Example in Java
A method (or message) in object-oriented programming (OOP) is a procedure associated with an object class. A Java example with source code and sample output.
Static Class and Its Usage in Java
Static Class and Its Usage explained in Java, with a complete example program, its sample output, and a clear code walkthrough.
Static Function or Method and Its Usage in Java
A Java example program demonstrating Static Function or Method and Its Usage, complete with the source code and expected sample output.
Default and Parameterized Constructor Example in Java
Default Constructor: A Constructor with no argument is called default Constructor. A Java example with source code and sample output.
Constructor Chaining Example in Java
Constructor chaining is calling a constructor from the another constructor of the same class. A Java example with source code and sample output.
Singleton Class using Private Constructor Example in Java
Singleton Class using Private Constructor in Java: a complete example program with source code and sample output, explained step by step.
Constructor Overloading Example in Java
A constructor in a class is a special type of subroutine called to create an object. A Java example with source code and sample output.
Simple Class and Array of Object Example in Java
Simple Class and Array of Object in Java: a complete example program with source code and sample output, explained step by step.
Multiple Inheritance using Interface Example in Java
A Java example program demonstrating Multiple Inheritance using Interface, complete with the source code and expected sample output.
Single Inheritance Example in Java
Single inheritance enables a derived class to inherit properties and behavior from a single parent class. A Java example with source code and sample output.
Multilevel Inheritance Example in Java
A Java example program demonstrating Multilevel Inheritance, complete with the source code and expected sample output.
Hierarchical Inheritance Example in Java
Hierarchical Inheritance in Java: a complete example program with source code and sample output, explained step by step.
Create Matrix Example in Java
Create Matrix in Java: a complete example program with source code and sample output, explained step by step.
Sum of Three Numbers Example in Java
A Java example program demonstrating Sum of Three Numbers, complete with the source code and expected sample output.
Find All Substrings of a Given String Example in Java
A string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. A Java example with source code and sample output.
Heap Sort Example in Java
Heapsort is a comparison-based sorting algorithm. A Java example with source code and sample output.
Twin Prime Example in Java
A twin prime is a prime number that has a prime gap of two. A Java example with source code and sample output.
Java Scanner Class Example in Java
Learn how to read user input in Java using the Scanner class with nextInt, nextLine and nextDouble, including a complete example and sample output.
JDK JRE JVM Explained Example in Java
JDK JRE JVM Explained explained in Java, with a complete example program, its sample output, and a clear code walkthrough.