Every variable has some data type in JAVA, this data type decides what this variable will store. Some basic data types are as follows:
String: As name describes it is used to store strings(Sequence of alphabets) in it. It is used as String s = "Its JAVA course";
int: as name shows it stores integer value. It can't store decimal value e.g int a = 20;
float and double: These two data types are used to store decimal values, difference in them is the usage of memory. More you will learn with time. It can be used as float x = 2.99;
2. Simple Program That Uses Strings:
Make new project named StringTest as described before.
Write following commands in main method.
String x = "Java ";
String y = "Course";
String z = x+y;
System.out.println(z);
Test this and try different such statements.
3. Simple Calculations:
Make new project named BasicMaths as described before.
Write following commands in main method.
int a =12;
int b =3;
int c,d,e,f,g;
c= a+b;
d= a*b;
e= a-b;
f= a/b;
g= a%b;
System.out.println("Addition : "+ a +" + "+ b +" = "+ c );
System.out.println("Multiplicaton : "+ a +" * "+ b +" = "+ d );
System.out.println("Subtraction : "+ a +" - "+ b +" = "+ e );
System.out.println("Division : "+ a +" / "+ b +" = "+ f );
System.out.println("Remainder : "+ a +" % "+ b +" = "+ g );
Test this and try different such statements.
For Discussion I Will Be Online After 9 PM
(Pakistan) Daily.
You Can Also Leave A Thread At FORUM Which Will Be Answered In 24 Hrs.
Your Assignment After This Lecture Is To Practice All These Tasks And Give Some New Examples At FORUM.