I got some function I would like to use in multiple classes, what is the proper way to do that ?
I thought creating a class and set my functions to static… or maybe implement this class who need these functions ?
What do you think ?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If this method does not use any instance variable of any object, it can (and probably should) indeed be made static, which makes it available from everywhere (provided it’s also public).
Good examples of such stateless, globally available methods are the methods from the
java.lang.Mathclass.