Hello, i want to know what's the use of new keyword while Initializaing the array in JAVA.How it's helping in java whether same like new in c++ or malloc in c

Edited 4 Years Ago by Ezzaral: closing

Sounds like an assignment question, can you tell us the answer from whatever research (reading books or the resources on the web) you did ? We will add to it or correct you even, if we see you have put in the effort to really find out.

Why don't you look it up on the internet. Try finding answers to such questions by searching them on the internet, instead of asking forum members. This will save you time too as also you would have the oppurtunity to learn something else with that.

Comments
Unhelpful. Always answer instead of referring elsewhere for the people who get to this page by searching.

If you dont know answer means, don't answer.For this simple questions itself you cannot able to answer, very shame to youuuuuuuuuuuu........

Comments
Lazy, lazy, lazy. Do your own homework buddy.
Check your attitude. No one here is obligated to help you at all. Think on that before you post.

.For this simple questions

Thats exactly where my previous post targets, if you think this question is so simple, why in the first place do you need others help.

PS : I confess, I only got to know the new keyword in java through your post. Actually to tell you the real thing just because of that I never created any object in the Java language all this while. but I hate you for spoiling my cover-up and also really hope that someone posts the correct answer to this question, cause, psst...be silent, I am going to need some objecst in my upcoming project. ;) I really hope my boss isn't on daniweb. :(

Comments
Excuse me, what is an Object? :)

If you dont know answer means, don't answer.For this simple questions itself you cannot able to answer, very shame to youuuuuuuuuuuu........

since it is a 'simple' matter to you, why don't you educate us, those who are to ignorant to be of any assistance, and explain to us what it means/does, ...

since it is, as you stated, a 'simple' question, either it is too hard for you to understand, or you are trying to teach/explain something to us, or (what my personal opinion would be) this thread is completely useless, either to you.

so, if you don't know the answer to your question, I would suggest you read and follow up on the answers given to you by Stephen and Verruckt. they are just pointing out that it is in no possible way in your best interest for us to hold your hand as long as possible.

that would end up in a situation like a kid going to school for the first day, not being able to eat on his own, since his mummy has brest fead him his entire life. eventually, people expect you to grow up and do some eating yourself.

so, either you read up on the subject, tell us what you think it is and ask us whether yes or no your vision on the subject is correct, either you instruct us on the new-keyword, or you just stop posting in this thread

new keyword dynamically allocates memory for an object..

http://java.sun.com/docs/books/tutorial/java/javaOO/objectcreation.html

refer to the above link....
and you two plz dnt fight here....its nt a battleground..

Good you woke up from your sleep, but before posting please check the dates. Nobody was fighting on the thread and whatever the matter was was long closed before you decided to reopen it by bumping the thread. And one more thing the OP is certainly not waiting till now to know what the new keyword really does.

new keyword in java is the way of creating an object class - hope this helps

Considering the fact that the O.P. asked the question in Feb 2009, I am guessing he already got the answer or gave up and chose a different career :P

The new keyword in java programming language is used to create a new instance of a class or an array. Keywords are basically reserved words which have specific meaning relevant to a compiler. The new keyword allocates new objects and initialize them.

Syntex: Here is the syntax that displays how to create an instance of a class or an array by using the new operator.

Creating a simple java object (non array object) by using the new operator.String sName = new String();


Creating an array object by using the new operator.Array arr = new Array();


Note: Here are some points that must be considered while creating an instance of a class or an array.

The argument that follows the new keyword must be a class name followed by a series of constructor arguments having parentheses.

The collection of arguments must be same as the signature of a constructor for the class.

The variable type on the left side of the assignment operator must be compatible with the class or interface which is being instantiated.

no, serious????
the one who did not knew that, stopped reading this forum over a year ago.
the answer has already been given (a few times now)
stop reviving dormant threads