Previous
Next

## Simple Java Programs For Complete Beginners:

Interested in Java Programming Language? Then you are in the right place. By the way, Thanks for landing on this page. Here you will see Simple Java Programs For Complete Beginners.

## List of Java Programs For Beginners

1. Java program to demonstrate the use of Harmonic Series.

2. Java program to display a number of even, odd and sum of even, odd program.

3. Java program to find a substring in the given string.

4. Java program to arrange the given strings in Alphabetic Order.

5. Java program to implements Addition and multiplication of two Matrices.

6. Java program to demonstrate the use of Constructor.

8.  Java program to demonstrate the use of overriding Method.

9. Java program for single Inheritance.

10. Java program for implementing Interface.

11. Java program on Multiple Inheritance.

13. Java program to demonstrate Exception handling.

14. Java program to demonstrate Applet program.

These are the complete list of Simple Java Programs For Complete Beginners. This consists of low difficulty level to the high difficulty level. Once go through it and you will be able to code very easily in the future.

## 1. Java program to demonstrate the use of Harmonic Series.

#### Harmonic Series:

It is a type of series which has an infinite series. It can also be called as the partial sum achieved by adding the preceding terms without limit.

(Or)

It can be defined as the sum of reciprocals of positive integers.

## Program

import java.util.Scanner;
class test
{

public static void main(String[] args)
{

System.out.println("Enter a Number:");

Scanner s=new Scanner(System.in);

int num=s.nextInt();

System.out.println("The Harmonic Series is:");

double result=0.0;

while(num>0)

{

result=result+(double)1/num;

num--;

System.out.println(result+" ");

}

System.out.println(" ");

System.out.println("Output:"+result);

}

}

## Output

Enter A Number: 5

The Harmonic Series is: 0.2 0.45 0.783333333 1.28333333 2.28333333333

Output: 2.283333333.

## 2. Java program to display a number of even, odd and sum of even, odd program.

#### Sum of Even & Odd:

In this program, you have to display the Sum of Even And Odd Numbers using Arrays Concept.

## Program

import java.util.Scanner;
class EorO
{

public static void main(String[] args)
{

int n,sumE=0,sumO=0;

Scanner s=new Scanner(System.in);

System.out.println("Enter the Number of Elements:");

n=s.nextInt();

int [ ]a=new int[a];

System.out.println("Enter Elements of Array:");

for(int i=0;i<n;i++)
{
a[i]=s.nextInt();
}

for(int i=0;i<n;i++)
{
if(a[i]%2==0)
{
sumE=sumE+a[i];
}

else
{
sumO=sumO+a[i];
}

System.out.println("Sum of Even                                              Numbers:"+sumE);

System.out.println("Sum of Odd                                               Numbers:"+sumO);
}
}
}

#### Output

Enter The Number of Elements:5

Enter The Elements of Array:

1  3  2  6  7  9

Sum of Even Numbers: 8

Sum of Odd Numbers: 20