Follow me on Twitter RSS FEED
Showing posts with label 3-Data types in java. Show all posts
Showing posts with label 3-Data types in java. Show all posts

Java Premitive data types (boolean,char,byte,short,int,long,float, double)





අපි අද පාඩමෙන් බලමු java හි Data types ගැන.... Java Premitive data type හි data type 8 ක් අපි ඉගන ගන්නවා...





Java Primitive Data Types (8)

Type
Contains
Default
Size
Range

boolean

true or false false 1 bit NA

char

Unicode character
unsigned
\u0000 16 bits or
2 bytes
0 to 216-1 or
\u0000 to \uFFFF

byte

Signed integer 0 8 bit or
1 byte
-27 to 27-1 or
-128 to 127

short

Signed integer 0 16 bit or
2 bytes
-215 to 215-1 or
-32768 to 32767

int

Signed integer 0 32 bit or
4 bytes
-231 to 231-1 or
-2147483648 to 2147483647

long

Signed integer 0 64 bit or
8 bytes
-263 to 263-1 or
-9223372036854775808 to
9223372036854775807

float

IEEE 754 floating point
single-precision
0.0f 32 bit or
4 bytes
�1.4E-45 to
�3.4028235E+38

double

IEEE 754 floating point
double-precision
0.0 64 bit or
8 bytes
�439E-324 to
�1.7976931348623157E+308






දැන් අපි බලමු Data type use කරලා java program ලියන ආකාරය....මෙහිදී අපි කිසියම් Data Type 1ක කට අදාල variable program 1ක තුල use කරන්නේනම්, ඒවා කුමනData Type 1කට අදාලද යන්න හැදින්විය යුතුය.

උදා -byte a;
byte x=3;
double A=5.5;
boolean b=true;

දැන් අපි Data Type භවිතා කර program ලියමු. එහිදී මෙය වැඩිදුරටත් තේරුම් ගැනිමට හැකිවෙනු ඇත......


class MyProgram{
public static void main(String args[]){

int x=70;
double y=45.98;

System.out.println("x value is = "+x);
System.out.println("x value is = "+y);

}
}


මෙම program 1කේ x සදහා int Data Type 1 කට අදාල අගයකුත්, y සදහා double Data Type 1 කට අදාල අගයකුත්හදුන්වා දී ඇත. තවද System.out.println (sop) ක තුල x සහ y වල අගයන් print කර ඇත.
("x value is = "+x);මෙහි ලකුනක් යොදා ඇත්තේ සංඛ්‍යාත්මඛ එකතුවක් සදහා නොව. ඒ 2ක 1කට ලිවිම සදහාය....


මෙය පහත පරිදි run වේ............


class MyProgram{
.............public static void main(String args[]){

.............char x='Kamal';
..............boolean y=true;


...............System.out.println("His name is = "+x);
................System.out.println("He is a boy = "+y);

.............}
}

char Data Type ඇතුලත් කිරිමේදී එය ' ' ඇතුලට දමා ඇතුලත් කල යුතුය....
මෙය පහත පරිදි run වේ............

java program using char data type



අපි තව program 1 ක් ලියමු.

java program using long,int data type

මෙහිදී අපි * Operator 1ක භාවිතා කරල තියනවා. ඔයල Operators ගැන බය වෙන්න ඒපා..අපි Next පාඩමෙන් Operators use කිරිම ගැන කියලා දෙනවා...
මෙය පහත පරිදි run වේ............


java program using long,int data type
Related Posts with Thumbnails

ShoutMix chat widget
d