Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Java in General and the fly likes Working with OOP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Working with OOP" Watch "Working with OOP" New topic

Working with OOP

Robbie Harjes

Joined: Nov 09, 2003
Posts: 22
Ok... I want to use Object F in my new class defition. Is it okay/will it work to create a constructor with Object F (having no commands or expressions inside the constructor) so that I can have Object F available to methods declared in the new class?
Might have to read that again... Here's a little more illustrative approach:
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
I'm willing to help u out in your problem, but I found a little difficult in reading your explanation on your problem... Could u please explain it more clearly so that I can help you to solve your problem....

Co-author of SCMAD Exam Guide, Author of JMADPlus
Robbie Harjes

Joined: Nov 09, 2003
Posts: 22
I don't know exactly what to say...
Having a constructor, (with objects that I want "imported" so I can use them in the other methods of the class), that has no expressions or anything inside of it; it's sole existance is to "import" some other object..
I'm pretty sure it'll work, (I mean I could just skip this, and take the object as a parameter for each and every method, but that seems a little wasteful).
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Hi Robbie,
It sounds like what you're trying to figure out is how to innitialize a member variable in a constructor, something like

Here the constructor parameter "theName" is made available to all the methods of the class by storing its value in the member variable "name". Make sense?
[ December 17, 2003: Message edited by: Ernest Friedman-Hill ]

[Jess in Action][AskingGoodQuestions]
Robbie Harjes

Joined: Nov 09, 2003
Posts: 22
So I couldn't just:

I understand [/understood] all that, but I guess I was just wondering if I could get around it with less code... Thanks for the help!
[ December 18, 2003: Message edited by: Robbie Harjes ]
I agree. Here's the link:
subject: Working with OOP
It's not a secret anymore!