Need help with calling methods from classes - Java Assignment
I'm working through a Java assignment for school, and I've hit a road block about half way through it. The part I'm up to is asking me to add a method to a seperate .java file (MyString.java in this case) and then to call that method in my main program file. Don't get too confused with how the assignment is meant to work or anything, I only really need help with the code to call that method in my main file. I'm going to show you the relevant areas of code in both files and I'm hoping someone can help me out with the code to call that method from the class MyString.java.
Ok, here is the section taken from the class MyString.java:
public static String createID(C)
String message = C.substring(0.3).toUpperCase();
return message+= (int) (Math.random()*99 + 1200);
Basically what that's going to do is take the first three characters from the lastName field and merge them with a random number between 1200 - 1299 to create an Employee ID.
My problem is I really have no idea how to call this method in my main file below:
public static void createEmpID()
//JOptionPane.showMessageDialog(null,"In (2) createEmpID()"); <-- This is just filler text, I need the code for this part that will call the previously mentioned method.
I hope I've made this as clear as possible but if you need any further clarification let me know and I'll respond as soon as possible.
Thanks for taking the time to read my post and I hope to hear from someone soon.
Re: Need help with calling methods from classes - Java Assignment
It is a static method, so you'll call it on the class:
Note though that you must take care to spell and capitalize all your variable, method and class names precisely.