I’m sorry if this is an easy question, but I can’t seem to call my one method with parameters from another class.
Normally if I were to call my method, I would do it by it like so.
Class1
public static void main(String [] args){
Class2 class2Object = new Class2();
class2Object.myMethod();
}
Class2
public void myMethod(){
System.out.print("Hello");
}
The above is just an example, but if I had to pass a parameter into the myMethod method (for example an arrayList), how would I call it in my other class.
The actual method I need to call is below:
public void search(List<String> listOfWords) throws FileNotFoundException, IOException
Any help will be appreciated,
Regards.
You simply put a list in the arguments of the method when calling it:
You would probably benefit from reading a tutorial on methods arguments.