I’m new in Java (Eclipse), and I want to know if there is any way to create a file with some piece of code and just call it in the class.
Because I have a lot of different classes for different results but there is some code that don’t change from one to another (the menu for example) and I want to make this more practical when I have to adapt that code, without change class by class.
Is there any way to do this ?
I’m new in Java (Eclipse), and I want to know if there is any
Share
I accomplish this in my projects with classes I call Helper classes. I got the idea from the GoogleIO app source code. They have a class called the ActivityHelper. It does exactly what your are talking about, puts code that is used over and over in one place. Here is my MenuHelper class as an example. My menu is the same for a lot of my Activities so it made sense to do it this way…
And then the implementation in one of my activities