Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

[Updated] Java Tutorial #2

Lol at the post above

and nice tutorial i hate java but still this is very good.
nice tut again ^_^

(tooshort)
(Apr 16, 2009 10:29 PM)Psycho Wrote:  Java Tutorial #2



The syntax for instantiation is:
Code
ClassName identifier = new ClassName;

However, if the class requires any parameters to be passed, it could look this way:
Code
ClassName identifier = new ClassName(1, 2, 3);

The following is also valid:
Code
ClassName identifier;
identifier = new ClassName;
You just cleared up so much, thank you!
bump for better tutorial
Just a heads up on an error I found. I haven't finished reading yet though so I will edit if I find more.

Under arrays you wrote
Quote:
Code
int[] grades = new int[2];
grades[0] = 10;
grades[1] = 50;
grades[2] = 100;
The above example instantiates an array of int type, and of size 2.
Array indexes start at 0, so it can technically hold 3 values. In index 0, 1, 2 and 3.

Which is false. Since you made it size 2, you can only hold two variables on int type. In index 0, and index 1. You can not hold anything in indexes 2 or 3 as it will give you a size mismatch error. Just a heads up. Your program would also run an error above.

Thanks though for the tutorial, help me expand on some things I was lacking in.
I knew that part was wrong somehow :P My conclusion was slightly different though but it's good to know the way it is now, thanks TehPelix.
Even more (way more) thanks to you though Psycho, once again a great tutorial.
Will there be any more coming from your hand? They fit my entry exactly the way you write them right now (not for advanced people nor for complete retards :P)
Not a bad tutorial , but I think it would be wise to add a part on ArrayList in the array section . Also you should show how to create classes , and go over instance fields . Another part to add would be on the different data types such as int , boolean , char , double ..ect . Nonetheless good work .
Great tutorial :)

I'm learning Java in college atm, but I'm trying to work ahead so I can get more experience. This is the first tutorial I've read that helped me understand input.

Thank you :D
wow psycho!U just rocked !help me on exceptional handling pls :)
Another great tut. I just relized php seems to be similar to java because this looks kinda the same. Noob thoughts


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by Recycle Bin.Nov 6, 2015 09:36 PM 61 6,283 Nov 6, 2015 09:36 PM
Last Post: TheUnCola
[Java] by President HolyFeb 8, 2014 11:48 AM 3 187 Feb 8, 2014 11:48 AM
Last Post: Knautschtabak
[Java] by Canonsx130Dec 18, 2013 10:57 AM 21 1,147 Dec 18, 2013 10:57 AM
Last Post: leto12