Posts: 3
Threads: 2
Joined: Oct 2009
Reputation:
0
Hi all,
I'm working on a little java program and I'm using classes. Though, I'd like to make some methods to be able to be used by any class in the package. Is this possible? And if so, can you provide an example on how to declare this?
Thanks,
Combus
Posts: 101
Threads: 6
Joined: Oct 2009
Reputation:
8
10-08-2009, 04:33 PM
(This post was last modified: 10-08-2009, 04:34 PM by Psycho.)
Well, think about it. If you have many large methods that you want to re-use, then a class for them is definitely suitable.
If they're just a couple of small methods, it's not gonna hurt to redefine them all in their own classes. ;)
I do not know of a way of doing what you're trying to do, though.
Posts: 119
Threads: 14
Joined: Oct 2009
well yea of course its possible
Posts: 119
Threads: 14
Joined: Oct 2009
(10-08-2009, 06:18 PM)Psycho Wrote: Please post real answers; the members who create threads want solutions to their problems, not answers that state "it's possible."
Eustaquio has that covered
Posts: 20
Threads: 1
Joined: Oct 2009
Reputation:
1
couldn't you just create a void method in one of the classes. I mean, if you put a new method in one of your classes and create an instance of those classes in your other classes, you could just use them.
class 1:
method comes ehre
class 2:
instance of class 1 -> class1.method()
Posts: 111
Threads: 32
Joined: Oct 2009
Reputation:
0
You could also just make the method static on some conditions.