Solution:
Hello Gavin, I hope you are enjoying programming with problem-solving. The problem occurred in the very first line of your program.
In java, you need to have at least one public class in your program otherwise it not gonna run. You may have multiple public classes but mandatory is t least one. I hope you get my point. Let’s write the program again with a public class,
public class AddingNumbers{
public static void main(String []args){
int x = 10;
int y = 15;
int sum = x+y;
System.out.println("Sum is: " + sum);
}
}
Now your program looks good and you are all set to go. This program should compile error-free and give an output:
Sum is: 25