PDA

View Full Version : Intro to Java


masterof_none
18-05-2003, 11:23 PM
salam sejahtera to everybody,
first of all, thanks for your support.
I hope for now, my posting is going to be short since I'm not fully recovered from this syndrom.
Anyway, I'll give you an overview about why we create this Java slot in the first place and what can you expect from our humble effort.

Warning:
Everything that I write is just according to my understanding abt Java.
It might not be accurate. So, for those who spot my mistakes, please post it to the forum.Because,"to err is human,"

You may ask:
Why do you write this?
Actually, I'm writing this Java slot just for hobby while refreshing my memory about Java. Since programming really need everyday's practice, this forum on Java may suite my needs.

Can I join this forum if even I've never done programming?
Yes. You're welcome to come and post. Anything that you think you don;t understand, please don;t hesitate to post. I'm sure a lot of RC members know abt this good stuff already..they, including me will try our best to help you.

What is a programming language?
Language to tell computer what kind of stuff you like your computer to do.
Obviously, we can't speak Malay or English to our PC or laptop. or can we?

What is Java?
Not to confuse with an island in the south of Malaysian peninsula, or a mere cup of coffee, Java is a powerful programming language.

What's the difference between Java and C++?.
Too much to talk abt here, but the obvious ones are:
1. In Java, everything is pointers.In C/C++, not all of them are pointers.
2. In Java, all objects are dynamically allocated. but that's not the case in C++.
There are much more, I guess that;s enough for now..
But Java evolves from C++, so, people who'd been program in Java shouldn't have difficulties writing a Java program. The syntax is kinda same.(although not really)

Actually, I don;t have to write any tutorials because they;re tons of tutorials out there in the cyberspace.Here, I give you the official Java website.

http://java.sun.com
For those who've never learn Java, that;s your homework, please go through the tutorial in that official Java website. Tomorrow, we;ll review the history of Java before we write, compile and run the program.

babai and have fun!

masterof_none
20-05-2003, 09:23 PM
oops,I've made a mistake on the last posting.

there;s no pointers in Java but only references. pointers is the variable that store the memory and when it get dereference, it would give the value of the variable at that memory.

//you may review C++ first.

e.g

int blah = 89;
int *blah2; //see, the star

blah2 = &blah //get the memory location

so,

//this is C++
cout<< "this is blah"+*blah;

will print 89.

so, the difference between the reference and pointer, then, is the *,
pointer has that star (*), while reference not.

reference can be created like this;

//C++

int blahblah = new int;

blahblah now is a reference to a memory allocated on the fly for int,
but the memory is not yet allocated,....
so, to initialize blahblah,

blahblah = 90; // initialize, memory get allocated

cout<<"blahblah is "+ blahblah;

will print 90.

as we all know from the previous post, Java syntax evolves from the C++,
from example, above, the difference is just how to print.
in java, there is one long syntax for that,

System.out.println("I'm "+blahblah+"th RC memeber");

will print , I'm the 90th RC member.

as I hope at the end of this summer. ;-)

When I first time learn abt pointers and reference, it's so confusing,,
that I think I better quit programming. But as you can see, thank God and thanks to friends, I'm now a happy programmer.

Why happy?..because I like to see my program working.

masterof_none
21-05-2003, 12:45 AM
for those who never program, or forgot how to,
you may not want to see this.
you may want to read the history of Java first.

...............................................................................

memory allocation is the mother of bugs.

so, what I've done on the last post:

int blah = new int;

while this is short, we must understand why we did this.
this is the sort cut of :

int blah; // initialize only , no memory allocated yet.

blah = new int; //allocate memory.

now, blah is the reference, so...to be safe, always initialize new variable
with zero;

blah = 0;

so, in the last posting, I;m not quite right by saying

int blah = new int;

as 'no allocation of memory yet.
We'll talk more abt memory allocation when we get there in the series of postings.

bachok83
21-05-2003, 10:43 PM
you may want to write what is cout what is int...because to some people it may be so confusing...

nevermind, here it is
the int is integer. So you kinda declare that "blah" is your integer. So computer will understand that. Then, you declare the value for blah
let say you put this

int blah = 90;
note that you must put ; or we call is colon, to end syntax just like what i've show above.

cout is to print out everything you want to print on your screen. For example, you wanna print Hello World on your screen using C++, you may want to write this

cout>>"Hello World";

i suppose this slot is for Java, as i'm also learning Java. So we just stop here for C++.
Good Luck guys......

littlebigone
20-09-2003, 07:40 AM
just looking at the old posts and saw this mistake.

cout << "Hello World";

bachok83
20-09-2003, 09:18 AM
hahaha my bad...

sorry for that silly mistake.. :P

masterof_none
20-09-2003, 12:07 PM
I have to admit that I'm a Java fan. But half way through the tutorial, I don't think I'm fit enough to keep on posting . So, I decided to back up and play more with it. Now, I try to open a project site based on Java..and will be available shortly...and I think it's wiser for us to collect bunch of tutorials out there and put it in one place...and help each other understanding it...and..if we have time, we can do write some stuff just want to see how it works.

littlebigone
20-09-2003, 01:15 PM
Speaking of tutorials, this is the tutorial I used to learn C++.

http://www.cplusplus.com/doc/tutorial/

Don't think it is meant for people with no programming experience but if you know Java or C and want to learn C++, this should get you through.

But the best thing always is of course, practice.

chenchow
20-09-2003, 10:55 PM
talking about programming, anyone has any idea of how tough or how easy Python is?

masterof_none
20-09-2003, 11:37 PM
I heard it's an Object oriented but it's more like Perl. kinda like script language

oreoboy
10-10-2003, 11:00 PM
hye every buddy.. or should i say assalamualaikum...?

so.. i'm ssoooooo new here... nothing much i know about programming.. except.. C++, i used to learn it in my dip course.. as for java.. i just forgotten why i've learned... ayaaaa... mati wooo...

anyway... nice for being here... from nuuuu hah kat malaysia nuuu... hehehe...

Randomphantom
30-04-2004, 02:21 AM
These are some nice tutorials for C++/Java, all free downloads and they even come with the source.

Bruce Eckel's Mindview
http://www.mindview.net/Books/DownloadSites/

jiinjoo
30-04-2004, 04:17 AM
yeah, but they are kinda steep for the beginner. But if you're into details and "exactly how things works", Bruce is a very good author. He's currently my 2nd reference book when Google can't give me a one line answer.

But still, I recall that there are quite a number of experienced people here, when put together, can answer any question you have on Java etc. So go ahead and post your questions if you really don't understand after reading your book.

bt3on9
13-05-2004, 02:39 AM
i am not sure whether it is relevant for me to post this. anyway, i would suggest you to read the Java Language/Platform White Paper written by the creator itself, James Gosling. try to search it in http://java.sun.com. it will really give you a real clear picture regarding Java and how it differs from C++ and other related programming languages. of course Bruce's Thinking in Java is another good reference to kick off if you are serious into Java.

da-hype
13-05-2004, 02:53 AM
I have to admit that I'm a Java fan. But half way through the tutorial, I don't think I'm fit enough to keep on posting . So, I decided to back up and play more with it. Now, I try to open a project site based on Java..and will be available shortly...and I think it's wiser for us to collect bunch of tutorials out there and put it in one place...and help each other understanding it...and..if we have time, we can do write some stuff just want to see how it works.

lol after doing a LOT of c++ for school and hIRC (www.hirc.org), 1 semester of java... made me fall in love all over again :p I might post some tutorials here if needed... or some of my school assignments. I'll do it after my summer classes are done :P

masterof_none
13-05-2004, 09:35 PM
Thanks da-hype.
the idea of tutorial has been one of the first thing that I have in mind when we first creating Recom. But, till now, it's still hasn't materialized yet.. (actually, we plan to become the Malaysian SourceForge...).