Passing Object references?
Does anyone know how i could go about passing in a reference
to an object? I want to call the static method without creating an instance of this class, so when i call the FileGrabber method
i just have to use the class name. I not sure how i should go about doing this without having to define a constructor for this class. Any suggestions?
Code:
import java.io.*;
public class FileGrabber{
private static FileReader fr;
private static String filepath;
static void setFileReader(JTextField jtf){ want to pass in reference to a JTextField.
try{ // path for file to be encrypted.
filepath = jtf.getText();
fr = new FileReader(filepath);
}catch(IOException e ){System.err.println(e);}
}
}