Benefits Of Data Types
The various datatypes allow the developer to describe how the data is to be stored inside a program. It also allows the developer to understand the maximum and minimum values that may be stored there. Programmers benefit from data types because it differentiates from different data for example, an integer will only store whole numbers and the computer and IDE's know only to store this type of data. In string this will only store words enclosed in quotations. this sets apart different data from each other and makes it easier for programmers to code.
In some cases, the 'bool' type for example, indicate how the data is to be used. A bool variable may have only 1 of two possible values, either true or false. An int (or any variant of int) may not contain fractional values, and so on.
integer - this stores denary data in the variable for example you could have
int iNumber = 7;
the int is storing the phrase iNumber and that is = to 7
if/else - the if statement executes a certain part of the code if the value is true for example
int iTrue = 7;
int iFalse = 10;
if (iTrue < iFalse) {
System.out.println("This is True");
}else {
System.out.println("this is false");
}
this is saying if iTrue is less than iFalse then execute the first System.out.println but if iTrue is bigger it will execute the else statement.
char - the char variable stores an alphabetical letter for later use. For example
char cFirstInitial = 'J';
this will store the letter J until declared.
String - The string variable will hold a piece of text. For example.
String sMyName = "My name is Jeff";
this holds the value My name is Jeff to use in a println or anything.
double - the double variable will introduce the point system into number. For example.
double numberone, numbertwo, Answer;
numberone = 10.5;
numbertwo = 12.9;
Answer = numberone + numbertwo ;
System.out.println("The answer is " + Answer);
the double holds the numbers 10.5 and 12.9 then is added together to show the answer.




