I have two files in the same directory namely Main.java
and Functions.java
The content of Main.java
is this:
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String s = scan.next();
Functions you = new Functions(s);
System.out.println("Your name is " + you);
}
}
And Functions.java
:
public class Functions {
public String name;
public Functions(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
I manually compile and run them on my terminal. So this is what I did:
javac folder1/folder2/*.java
And after
java folder1/folder2/Main.java
But it gives me an error of this:
error: cannot find symbol
Functions you = new Functions(s);
symbol: class Functions
Even though they are on the same directory, it will still give an error.
Edit: I interchanged my code for compiling and running. Sorry for that.