This is our first program of java. This is a very basic program of java. It explains how to declare class, main function ,variable inside java. It also explain how we can print any value to output.

 

 

This program adds two number and display their sum .You can do any type of operation

Here like subtraction(-),  multiplication (*), divide(/) (just replace + sign by that operation sign);

 

 

Save this file as variable.java

To Run this program, type following lines in command prompt:

C:\>:javac variable.java

C:\>:java variable

Lets us begin with some more good examples .The next program describes how we can

Use the features so far we have learnt.

 

This program calculates area of a circle, given the radius of circle .You can change value of radius to calculate the area of any type of circle.

 

Save this file as Area.java

To Run this program, type following lines in command prompt:

C:\>:javac Area.java

C:\>:java Area

Java Program:Addition of two numbers

Java Program:Calculation of area of circle.

This program describe how  char variables are stored in java.

 

 

This program demonstrate character variables.

 

 

Save this file as chardemo.java

To Run this program, type following lines in command prompt:

C:\>:javac chardemo.java

C:\>:java chardemo

Java Program:Demonstrate character variables.