aspose file tools*
The moose likes Beginning Java and the fly likes cannot create new object of a class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cannot create new object of a class" Watch "cannot create new object of a class" New topic
Author

cannot create new object of a class

Ziyoda Mirkhonova
Greenhorn

Joined: Mar 16, 2006
Posts: 10
Hi everyone,
I am now learning classes and methods. I have problems with calling new object as instance of a class. Look at this:

University canteen wants to have a computer based system. They want to have a computer program that will allow them to order food and carry out transactions.
The manager should be able to order pies and somosas and pay for them using this program.
She/he(manager) will also be able to sell these goods to students with this new system.

And I programmed like this:



As you see wouldn't work!
Also, I tried to save different classes in different files, but I encountered same problem.

I will be happy to receive your help. Sorry for taking your time and energy!
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi,

Please check the code. I didnt change your business logic, I just changed few lines.



bye for now
sat
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

I think that the question should be closed now. Because second code is running fine.


The Best way to predict your future is to create it - Every great individual common man
Ziyoda Mirkhonova
Greenhorn

Joined: Mar 16, 2006
Posts: 10
Hi, Satishkumar Janakiraman,
thanks for corrections!!! Stop, don't lock this. It works, but I don't understand one thing.
1) Why did you do extends?


Does it mean that first, you create many classes and the last of them must be public? When you say extends it means, one class IN the other?

2) Also, does it mean that you cannot use any static when you have a lot of classes?

Thanks once more!!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: cannot create new object of a class