Java Examples

Java is another general purpose programming language and supports object-oriented programming concepts like polymorphism, inheritance, etc.

Java was created by Sun Microsystems and since then many programmers use Java programming language to write network based applications and business applications. You can also write games using Java programming language.

A list of Java programs in given below for following purpose

  • 1. Learn to program in Java by practicing these programs.
  • 2. Learn the Java programming concepts using these examples.
  • 3. Write similar programs on your own.

Prerequisites for Java Examples

Programming is all about doing, not just learning concepts and syntax of the programming languages. To learn Java you must use the practical approach – practice as many example programs you can. This will lay a strong foundation for you to learn higher and complex programs. To practice Java you need following.

  • Java Compiler – there is two way to install a Java compiler. First, you can install NetBeans or Eclipse with latest Java Development Kit ( JDK ). Second, Install the latest JDK version and work with command line utility.
  • Java Tutorial – before you practice example programs, learn the basic Java concepts to get started.
  • Pen and Paper – if you try new inputs for example Java programs and want to verify the results, make use of  pen and paper and solve the problem manually to verify outputs. Especially, in case of math programs it is true.


Books serve as alternative resource to learn by example. We recommend two good Java programming books that contains several examples. You will have more examples to practice and learn. Do read the reviews for each book before you decide to get them.

amazon java2
amazon java3

Note: We earn a small commission when you make a purchase.

Java Math Programs

This section consists of all programs that solve mathematical problems from simple algebra to advanced calculus.

Java Operators

This section you will find all programs that use Java operators like assignment, arithmetic, logical, bitwise shift, and so on.

Java String Programs

This section is for all types of string related programs in Java. It will consist of demos for different string classes.

Java Array Programs

This section consists of all programs and demos consisting of arrays in Java language. There are two types of arrays in Java – single dimension and two dimension.

Java Class & Object Related Programs

This section we will list all examples demonstrating Object-Oriented programming with Java and programs that are built using these principles. At the end of this section, we include some mini-projects in Java language.