Data Types in Java
Submitted by donbermoy on Saturday, December 27, 2014 - 10:41.
This tutorial will teach you how to understand what are the variables in java. A data type refers to the type of data that can be stored in a variable, means that a variable needs a data type to save space in the memory for allocation.
So, now let's start this tutorial!
1. Open JCreator or NetBeans and make a java program with a file name of variables.java.
2. Now, we will initialize variables with their own data types in java.
An int data type contains a whole number. It is 32-bit signed two's complement integer,
A String data type contains text and numbers.
A char data type contains only a single character.
A double data type contains a decimal value of numbers.
A boolean data type returns only a True or False value.
A byte data type contains a small value of integer. It is four times smaller than an int and is used to save space in large arrays.
3. To display the declared variables in their different data types, have this code below:
Here's the full code of this tutorial:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- int shirtID = 0;
- char colorCode = 'U';
- double price = 12.01;
- boolean good = true;
- byte num = 24;
Output:

- public class variables {
- int shirtID = 0;
- char colorCode = 'U';
- double price = 12.01;
- boolean good = true;
- byte num = 24;
- }
- }
Add new comment
- 25 views