I don't know how to return the value of the string here, in short, I need the output of this string that is stored in the function:
public Object Directory(String directory) {
String directory1 = "directory";
return directory1;
}
public static void main(String... args) throws Exception {
System.out.println(directory1);
}
This is my interface in another file:
public interface Interface extends Remote {
Object FileName(String filename) throws RemoteException;
Object Directory(String directory) throws RemoteException;
}
If I understand you. You can try so.
public static String Directory(String directory) {
String directory1 = "directory";
return directory1;
}
public static void main(String... args) throws Exception {
System.out.println(Directory("directory1"));
}
In Java you must declare the return type of a function. In your case you have defined the return type of Object
when you really want a return type of String
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.