Calling a void method into a static void main within same class
I am new to java programming and have bad programming writing skills and in great urge of the need of help.
I have a program with 6 methods, one method being the static void main
Code :
public class ExceptionHandling{
public void FileNotFound (String fileName){
}
....
public static void main(String[ ] args){
}
I just need help in placing FileNotFound into the static void main
I tried:
ExceptionHandling fetch = new ExceptionHandling();
fetch.FileNotFound();
...and received the error of FileNotFound(java.lang.string) could not be applied to ()
I have no idea what to do at all. Checked my textbook with no luck and tried everything my textbook gave examples of. Please help me!
Re: Calling a void method into a static void main within same class
You're trying to call FileNotFound with no arguments, but the method you made always needs to have a String (the filename) passed to it.
So you should use:
Code :
ExceptionHandling fetch = new ExceptionHandling();
fetch.FileNotFound("Some String");
or
Code :
ExceptionHandling fetch = new ExceptionHandling();
String filename = "filename.txt";
fetch.FileNotFound(filename);
Re: Calling a void method into a static void main within same class
Re: Calling a void method into a static void main within same class
You're welcome :-)
Glad I could be of assistance.