- Input and Output Instruction
- Mathematical Expression
- Memory
- Condition
- Jump

public class hello{
public static void main(String[] args){
System.out.println("Hello...");
}
}

Remember that java is a case sensitive language that means that for example in java this Case and this case is different
Now the next part is how these types of instruction which i have explained you above works in java . in most part instructions in most modren languages are combination two or more type of instructions . so first of all is
- Memory & Mathematical Expression
Well in most programming languages as well as in java variables are used to store data . they act in most part like mathematical variables.
Variables are of Many Types some of these are given below
-
byte can store one byte or 8 bits (0 - 255) or (-127 - 127)
-
char same as byte but stores one character instead of a number
-
int this is a type which most often used in programs . this is a 32 bit variable . it can store from 0 - 1073741823
-
double This varible is 64 bit varible which stores numbers with decimal or floating point numbers . the number stored in this type is like 0.32425 , 34.352463 , etc
-
String This type stores text messages or simply english sentences in it .
Now i will show you an example which will explain these concepts.
import java.io.*;
public class hello{
public static void main(String[] args){
byte b;
char c;
int i;
double d;
String s;
b = 5;
c = 23;
i = 3563;
d = 0.4353;
s = "Hello this is a test";
System.out.println(b);
System.out.println(c);
System.out.println(i);
System.out.println(d);
System.out.println(s);
}
}
its output is this
Now if you understand this concept you can also understand the concept of mathematical expressions
below is an example program.
import java.io.*;
public class hello{
public static void main(String[] args){
int a;
int b;
int c;
a = 5;
b = 23;
c = a + b*a;
System.out.println(c);
}
}
output of this looks like this
- Condition & Jump Statements
In most modern programming languages including java the concept of condition and jump are combined together .by combination of these two statements we get the following instructions
- if and else -
if statement is the basic condition statement in most programming languages . its function is similar to its name . if some condition is true it executes instruction written in its block otherwise it redirects it to else part if else part is mentioned other wise it does not executes its block here is an example program with its description.
Its Output is 6
public class hello{
public static void main(String[] args){
int a;
a = 0;
while(a<10){
Now in this last part I will show you how to take simple input from keyboard and show simple output on the screen . below is the program which take simple input from keyboard as a number in an int integer and outputs a simple output on the screen
import java.io.*;
public class hello{
public static void main(String[] args){
int a;
int i;
try{
i = System.in.read();
a = i + 15;
System.out.println(a);
}catch(Exception e){}
}
}
Output of the program is this
Now the explaination of this program is in the figure below
-
Arrays
Array is described as collection of elements each described by one or more index . in more common words array is type of varible in which you can store more then one value . each value can be accessed by its indicator called index .
here i will only show you some few basic types . once you have learned this you can learn rest from any advance java tutorial or documentation widely available on the internet
Well this is the example program and it description.
This is its output
Remember that number here [number] while reading or writing into your array can be any expression .
an expression is just similar to mathematical expression and can be any thing from a single variable name or single number to more complex mathematical expressions . just the values produced by it must be in limits from 0 to the maximum number of places you have defined in your arrays definition .
-
Function
function is the building block of any structured or object oriented programming language . a function is just like mathematical function . its like a machine you give it input it processes it and gives you output . and the similar machine can be used again and again. here is a figure describing a function.
In java every function is written in between a class never outside it .for simplicity write the function in different class as in your main class . here is an example program
import java.io.*;
public class hello{
public static void main(String[] args){
int a;
int b;
int c;
a = 3;
b = 7;
function t = new function();
c = t.sum(a,b);
System.out.println(c);
}
}
class function{
public int sum(int x,int y){
int z;
z = x + y;
return z;
}
}
its output is 10
so how does this program works . here is the description
- Classes
Well i am not going to explain you all the features of a class just its basics. Well a class is a collection of different variables and functions bunched together .
import java.io.*;
public class hello{
public static void main(String[] args){
int a;
int b;
int c;
a = 3;
b = 7;
function t = new function();
c = t.sum(a,b);
System.out.println(c);
c = t.sub(a,b);
System.out.println(c);
}
}
class function{
function(){
System.out.println("Hello...");
}
private int z;
public int sum(int x,int y){
z = x + y;
return z;
}
public int sub(int x,int y){
z = x - y;
return z;
}
}
its output is
So how does this program works here is its description
Well what public and private is that public are those kinds of functions and variables which are accessed every where in our program and private are those function and variables which can only be accessed in that class only.
So this was the beginners tutorial.I hope you have understand it well if not then you can give me comments on how to improve this tutorial .
the next tutorial on this blog will be about how to read and write files in java and how to create a database using mysql



















