aspose file tools*
The moose likes Beginning Java and the fly likes Instantiating an Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Instantiating an Object" Watch "Instantiating an Object" New topic
Author

Instantiating an Object

Rupinder Bains
Ranch Hand

Joined: Jul 23, 2002
Posts: 65
How do you instantiate an object??
Could somebody please kindly give me some basic examples. Thank You Very Much!
Rupes.x
Donald R. Cossitt
buckaroo
Ranch Hand

Joined: Jan 31, 2003
Posts: 401
There is an excellent tutorial here. and deeper in the same tutorial
doco
[ April 18, 2003: Message edited by: Donald R. Cossitt ]

doco
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
To instantiate an object, simply declare a reference and use the new keyword to create an instance for that reference:

Here I assume that you have already written the declaration for MyClass. It must include a constructor that takes no arguments. If you wish to use a constructor that takes arguments, you put them inside the () as you would with a regular function call.
Since the API already has a lot of classes declared for you, you may wish to instantiate one of them first since you wouldn't have to write all the code for a class that way.
HTH
Layne


Java API Documentation
The Java Tutorial
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi Rupinder
How do you instantiate an object??

If it is not clear,please feel free to ask.


Francis Siu
SCJP, MCDBA
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
My class is smarter than siu's, it can write chinese with its feet:


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi Rupinder
CCNA is about the network application.
Some hardware are developed by CISCO.
humm.....
Can you point out where Michael instantiate an object in the code?
If you can point out where,I think you can understand the concept of instantiate an object.
Michael is a funny bartender who always help people to answer the question, and the code is funny too,isn't it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Instantiating an Object