.
├── addition
│ └── Add.java
└─ main.java
This is the current file structure of my program. And these are the contents of main.java. and Add.java respectively.
import java.util.Scanner;
public class main {
public static void main(String[] args) {
System.out.print("First number: ");
var user_input = new Scanner(System.in);
int x = user_input.nextInt();
System.out.print("Second number: ");
int y = user_input.nextInt();
var result = addition.Add.add(x, y); // <-- error in this line
var output = x + " + " + y + " = " + result;
System.out.println(output);
}
}
public class Add {
public static int add(int x, int y) {
return x + y;
}
}
I am unsure how I'm supposed to import the Add class into main.java. Not sure if it matters but I go to the root of the project and run javac *.*. To compile all the java source files.
packages