JAVA EDITIONS
Java compiler can be broadly classified into three
editions: Standard Edition, Micro Edition and Enterprise edition. Standard
edition is generally used by normal developers which comprises a compiler to execute
and run a code. Micro edition is developed exclusively for users who develop
Java code in mobile devices. Enterprise edition is designed for small- and
large-scale companies.
DATA TYPES IN JAVA
Data types are used to store various formats of data
and different syntax is used for storing character, integer, floating
variables, etc. Data type in Java is sub-divided into two categories: Primitive
and reference data type. Reference data type stores variables which are little
complex than primitive data type.
All the basic
operations can be done using primitive data types. In order to use user data in
a more advanced and proper manner, reference data type is used.
·
Numeric data type includes numbers
like 1,2,3…
·
Non-numeric data type includes alphabets
like a,b,c…
·
Integer data type includes all
integers like 1,2,3…
·
Floating data type includes decimal
value numbers like 1.1, 1.2, 1.3…
·
Character includes all alphabets like
a,b,c…
·
Boolean data type is used in
applications which imply True or False statements
All the primitive data type must have their size defined by user. Based on the usage, suitable data type has to be selected.
|
Primitive Data type |
Size (in bits) |
Values |
|
Byte |
8 |
-128 to 127 |
|
Short |
16 |
-32,768 to 32,767 |
|
Int |
32 |
-2,147,483,648 to 2,147,483,647 |
|
Long |
64 |
|
|
Double |
64 |
64-bit floating point numbers |
|
Float |
32 |
32-bit floating point numbers |
|
Char |
16 |
All alphabets |
|
Boolean |
1 |
True/ False |
·
Byte can be used to store integers
only from -128 to 127. If user wants to store the value 211, byte cannot be
used.
·
To store 211, short, int and long can
be used. It’s always better to choose data types depending on the need. To
store the number 211, if user chooses long data type it occupies 64-bit memory
space and hence it leads to storage problems. Hence to store 211, ‘short’ data
type is sufficient.
·
Boolean is used to store either True
or False and hence 1 bit is enough.
Data type is necessary in order to
execute even a single line code in Java.
Syntax to define an integer:
int
number=211211211;
Here ‘int’ is the data type, ‘number’ is the variable used to store the integer value. Here the value 211211211 is assigned to the variable ‘number’.
Java code to print an integer value
class primitive{
public static void main(String
args[]){
int no=211211211;
System.out.println(no);
}
}
Initially, a classis defined which is named as ‘primitive’. Earlier versions of Java required the package declaration but version 15 JDK does not demand it. 211211211 is the number assigned to the variable ‘no’ and is declared as integer data type. For printing the number, System.out.println(no) is used.
Output
The same code was also run in an online Java complier and the results were also obtained correctly (ONLINE COMPILER ).



1 Comments
🔥🔥
ReplyDelete