DATA TYPES IN JAVA PROGRAMMING Tccicomputercoaching.com
In this article we will learn about the java
data types.
Variable is a memory location where we can
store the data. There are three types of variables: local, instance and static.
There are two types of data types in java, primitive and non-primitive.
Data Types in Java
In
general every programming language is containing three categories of data
types. They are
Fundamental or
primitive data types
Derived data types
User defined data
types.
Primitive data types
Primitive data
types are those whose variables allows us to store only one value but they
never allows us to store multiple values of same type. This is a data type
whose variable can hold maximum one value at a time.
The
Java programming language is statically-typed, which means that all variables
must first be declared before they can be used. This involves stating the
variable's type and name, as you've already seen:
int
gear = 1;
int
a; // valid
a=10; // valid
User defined data types
User
defined data types are those which are developed by programmers by making use
of appropriate features of the language.
In
java both derived and user defined data type combined name as reference data
type.
Student s = new
Student();
Integer Data Type:
Char Data Type
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Data
Type
|
Size(Byte)
|
Range
|
|||||||||||||||||||||||||||||||||||||||||||||||
Char
|
2
|
232767
to -32768
|
|||||||||||||||||||||||||||||||||||||||||||||||
Float Data Type
Data
Type
|
Size
|
Range
|
Number
of decimal places
|
Float
|
4
|
+2147483647
to -2147483648
|
8
|
Double
|
8
|
+
9.223*1018
|
16
|
Boolean Data Type
Boolean
data type takes zero bytes of main memory space because Boolean data type of
java implemented by Sun Micro System with a concept of flip - flop. A flip -
flop is a general purpose register which stores one bit of information (one
true and zero false).
Default Values
It's
not always necessary to assign a value when a field is declared. Fields that
are declared but not initialized will be set to a reasonable default by the
compiler. Generally speaking, this default will be zero or null, depending
on the data type. Relying on such default values, however, is generally
considered bad programming style.
User Defined Data Type:
Typedef
A typedef associates
a name with another data type. Here is the syntax of an IDL typedef:
The type can
be any basic IDL data type, a user-defined data structure
typedef
int unit;
If you
like this post then please share and like this post.
Visit us @ tccicomputercoaching.com
Call us @ 98256 18292.
Mail to tccicoaching@gmail.com
No comments:
Post a Comment