Back
You can take the below code as a reference to make a utility method:
public final class ExampleUtilities { // Example Utility method public static int foo(int i, int j) { int val; //Do stuff return val; } // Example Utility method overloaded public static float foo(float i, float j) { float val; //Do stuff return val; } // Example Utility method calling private method public static long bar(int p) { return hid(p) * hid(p); } // Example private method private static long hid(int i) { return i * 2 + 1; }}
public final class ExampleUtilities {
// Example Utility method
public static int foo(int i, int j) {
int val;
//Do stuff
return val;
}
// Example Utility method overloaded
public static float foo(float i, float j) {
float val;
// Example Utility method calling private method
public static long bar(int p) {
return hid(p) * hid(p);
// Example private method
private static long hid(int i) {
return i * 2 + 1;
I hope this will help.
Want to become a Java Expert? Join Java Training now!!
31k questions
32.8k answers
501 comments
693 users