PDA

View Full Version : Java Lesson-1.0.1.4


ravicplk
05-21-2008, 07:57 AM
Hello there..how is everything going fine? Ready for the lesson? Then lets get started.
So before we move on to the Practical lesson lets check out those data types in detail.

First lets peek in to integer group,

In the integer group there are four data types.

What are they?

Byte,short,int,long.
I know u are having a question in ur mind nee.? Why the hell that there are four data types to represent whole numbers.
The reason is this. When u want to use whole numbers in various ranges, u have to move to different data types.

http://img375.imageshack.us/img375/4633/java2ix7.jpg

So now I think u know why we have to use four data types when u want to use integers in a program. If u want to use a big number u have to use long and like that u have to choose the best data type for u r need. And very importantly u have to think about the bit width too. If u want to store a number such as 12 choosing long wont be a good idea. coz it has a bit width of 64. its really long and takes up more memory. So u have to think about the memory allocation too,

Next one, the floating-point group, so what are the data types in that group. As u can remember two data types are there. “double” and “float”.
Another table coming up..

http://img375.imageshack.us/img375/6708/java3nk5.jpg

So I think no need to explain this, similarly to the integers u have to choose the best one for u r work considering the memory allocation and also u have to think about the range as well.
Actually a double can hold real numbers
±4.94065645841246544e-324d to
±1.79769313486231570e+308d

And a float can hold
±1.40129846432481707e-45 to
±3.40282346638528860e+38
Hmm that’s quite a bit of numbers there, I am having a headache just seen them.

Ok now. We have a group called character and the relevant data type is “char”
Char is used to store characters in a java program. Characters can be numbers,letters and etc.. I like to mention something I have read from a book. if someone have done C or C++ before they might familiar with “char” before. But guys don’t mess up. Coz the char in a C\C++ is not similar to char in java.
In C\C++ char is an integer type that is 8bits wide. But in java ,it uses Unicode to represent characters.(Unicode defines a fully international character set and this can represent characters from all most all the human languages). To do this Unicode needs a bit width of 16. So it is different from C and C++. That is an additional thing ok.

Now next one, Boolean group. In the Boolean group u have “boolean” data type. Actually what is boolean. He heeeeeee… a word with seven letters. That is also true. Actually boolean is used to interact with the logical values. It can only one logical value from two possible logical values.
As an example take a look at the statement given below,
“I will pass the exam” (will I???) ok now there can be only one result which can br happened out of two possible results.
First one this statement can be true. And also can be false. But only one can be happened. If I pass this is true and if I fail this becomes false. So it is like that, only two values in boolean operations. “True” and “False”

So that is a detailed description about data types in java. Now u have to do a small exercise to get familiar with these data types.
Here is the code.

class example
{
public static void main(String args[])
{
byte a=12;
short b=1234;
int c=14256;
long d=235678;
float e=12.34f;
double f=123.43;
boolean g=true;
char h='y';

System.out.println(a);

System.out.println(b);

System.out.println(c);

System.out.println(d);

System.out.println(e);

System.out.println(f);

System.out.println(g);

System.out.println(h);
}
}

And for u r convenience I made a screen video (thanks for malinga ayya for the software)
So that is today’s lesson. Got to go now, c ya later.

ravicplk
05-21-2008, 07:58 AM
h-lfc-B4w3M

ravicplk
05-21-2008, 08:00 AM
ooooooops..
little addition. i forgot to say that when u are u using float data type u have to put a lower case "F" after the number,
"there are some zooming problems in this video..its my first one ne..i ll try to do better in the future,

TΞΞNSTAR™
05-21-2008, 08:10 AM
ahh i guess dis is d best lesson... tnx a looot bro.. d way u explaind Boolean Type ... nd d video is really good idea.... tnx again bro... keep it up..

ravicplk
05-21-2008, 08:13 AM
ahh i guess dis is d best lesson... tnx a looot bro.. d way u explaind Boolean Type ... nd d video is really good idea.... tnx again bro... keep it up..

thnanksssssss..mallizzzzzz

henderson
05-21-2008, 08:19 AM
Great lesson, keep up the good work bro.

And I like to add some more small points to the lesson

And always you can define numbers as follows,

long lng = 1034L;
double dbl = 324.322D;
float flt = 332.45332F;

and in characters if you need to define '\' character

you have to define it as
char ch = '\\';

and for unicode characters
define them like
char ch = '\u0021';

ravicplk
05-21-2008, 08:21 AM
And always you can define numbers as follows,

long lng = 1034L;
double dbl = 324.322D;
float flt = 332.45332F;

and in characters if you need to define '\' character

you have to define it as
char ch = '\\';

and for unicode characters
define them like
char ch = '\u0021';
thanks for the addition ayya..thanks again

TΞΞNSTAR™
05-21-2008, 08:22 AM
Great lesson, keep up the good work bro.

And I like to add some more small points to the lesson

And always you can define numbers as follows,

long lng = 1034L;
double dbl = 324.322D;
float flt = 332.45332F;

and in characters if you need to define '\' character

you have to define it as
char ch = '\\';

and for unicode characters
define them like
char ch = '\u0021';

tnx broo.... :D:D

Kalindugayan
05-21-2008, 08:28 AM
ela macho niyamai
ohoma yan

henderson
05-21-2008, 08:30 AM
thanks for the addition ayya..thanks again
you are welcome bro.:)

ravicplk
05-21-2008, 08:03 PM
hmmmm...seems to me is that likeness to these lessons got decreased
if there are any suggestions please mention

shanakaprabath
05-21-2008, 08:11 PM
:yes::yes::yes:thanks sooooooooooooooooooooooo much macho.......it's really nice:D:D

Shiwantha
05-21-2008, 08:14 PM
thanx machoo

niroshan84515
05-21-2008, 08:15 PM
:yes:
THX BRO
http://www.onvolcano.com/thanks.jpg

ereshthush
05-21-2008, 08:18 PM
gr8 work machan keep it up

TDM
05-21-2008, 08:23 PM
ela ela,,,,,
keep doing this great work....
thanKs mates

ravicplk
05-21-2008, 08:27 PM
i will do this,i want u guys to get something out of here,,if not..no point in putting these stuff ne

siri24
05-21-2008, 08:28 PM
elane

Malinga
05-21-2008, 08:30 PM
hmmmm...seems to me is that likeness to these lessons got decreased
if there are any suggestions please mention

comments nodammata lessons balanavane kattiya. registered user la vitharak namai anith ayath balanava athi. oyaa vade digata ma karagena yanna malli :D

Doggyluv
05-21-2008, 09:00 PM
hmmmm gud wrk