In the previous article, we study the program structure of java, and that java program will only run if contains no error. but in this lesson you'll learn about different types of data: string, number, char, float, double, long, byte, and boolean values. Check out the program below it prints the text "Hello" and the following data types.
The word "Hello" is printed as expected. Now let's print a number as well. I've added a second statement that prints the integer number 50. integer number is written without quotation Marks, While String or text is surrounded with quotation marks in java a text is called a "String" of characters. Now both the text and the number are printed. Extend the program to execute the number 70 on another line. look at the code above for your reference, But to make things more complicated there are different types of numbers in java, I've added "Long" integer at the top codes see it for your self, Long integer usually has an "L" behind it digits. Long integers are used for bigger numbers. Normally integers can only go up to 214783647, perfect! in addition to integer numbers java also supports "floating" point numbers. We've added the numbers 3.1415 in another line to declare a float integer, The standard floating-point number type in java is called double. There's also a "Float" type with less precession. There is also A boolean data type, which executes the "boolean" value "true",
A boolean value can be either "true" or "false". look at the code above we've added the boolean statement which prints value "true" and "false".
0 Comments