Types of data
Business requirement:
Write a java program for the addition of two numbers
45+45=90
public class Addition_Program {
;;;;;;;;;;;;;// statements
}
>>> cd desktop
Change directory
-> cd directory name
>>> javac Addition_Program.java
>>> java Addition_Program
In general, we have 5 types of data
1. Real numbers
2. Whole numbers
3. Alphabets
4. Words
5. Logical values
How many kinds of data are in java?
1. Real numbers (234, 1, 345, 12,90...) =========> integral data
2. Floating numbers (1.23, 324.1, 234.9... ) ======> floating data
3. Alphabets ( a-z, A-Z... ) ==================> char data
4. Words (Soft, practice,JAVA, salary...) ========> string data
5. Logical values (true, false) ================> boolean data
In order to define data in java, we need to follow some standard steps.
1. Define the data ( 5 kinds )
90
2. Give/assign some name to the data (variable name)
number1 90
3. Tell what type of data it is?(data type)
integral number1 90
4. Specify the scope of the data (access specifiers)
public integral number1 90
5. Data is going to change or not? (static)
static public integral number1 90
Ex:
>>> public class My_Program{ // access specifier,class keyword ,class name, start of the class.
static public int num1=20; //data is constant
static int num2=40; // access specifier is optional
public int num3=25; // data is not constant
int num4=80; // data is not constant, access specifier is optional
} // end of a class