gelbermann
gelbermann

Reputation: 15

Extract static methods from main() file in java

I'm quite new to Java and wrote a little to-do list project. At the beginning of the project I added a bunch of static methods to the file where my main() code is, and it got a little out of hand. I want to transfer these methods to another file. Is there a proper way to do this, or do I just have to create some sort of Behaviour class for these methods, and then in main() create an instance of it to call it's methods?

Upvotes: 0

Views: 340

Answers (1)

Ferdia
Ferdia

Reputation: 26

You can extract these methods to a separate class (say FooUtils), and then in your main method you can call them using the class name - FooUtils.someStaticMethod()

Depending on what you have, it may make sense to group your methods into different classes, or to make them instance methods.

Upvotes: 1

Related Questions