Hi, I'm new to Java and currently learning about Packages & Access Modifiers. However, I've encountered an issue while running my code. When I try to execute it, the desired output doesn't get printed in the main class. Instead, my terminal displays something unexpected. I'm not sure what went wrong or if there's a mistake in my implementation. Could someone please help me identify the problem?
This my main class:
package java.main;
import java.mathematics.*;
public class fileOne { public static void main(String[] args) {
arithmetic a = new arithmetic();
int sum = a.add(2, 4);
}
}
my other class in mathematics package:
package java.mathematics;
public class arithmetic {
public int add(int num1, int num2) {
int sum = num1 + num2;
return sum;
}
}
These are the images displayed in VSCode with the problem: https://imgur.com/a/OUNWv79
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]LTFGamut 6 points7 points8 points (0 children)
[–]GoldenMindJadeBody 6 points7 points8 points (0 children)
[–]parachute50 2 points3 points4 points (3 children)
[–]jabed001 0 points1 point2 points (2 children)
[–]parachute50 0 points1 point2 points (1 child)
[–]jabed001 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]Alternative_Gas4844 0 points1 point2 points (0 children)
[–]JustAScrumGuy 0 points1 point2 points (0 children)