I'm not sure what I did wrong here, this is my code
package methods;
public class example {
public static int sum(int x, int y){
return x+y;
}
public static void printSomething() {
int a = 1;
int b = 2;
System.out.println("The sum of "+ x + " and "+ y +" is "+sum(a,b));
}
public static void main(String[] args) {
System.out.println("Hello");
printSomething();
}
}
I want to print the sum of x and y is 3
x, andy, inside of theprintSomething()method that are not within the scope of that method, and this should prevent your code from compiling -- is this what is wrong? Solution: useaandbthere.System.out.println("The sum of "+ a + " and "+ b +" is "+sum(a,b));System.out.println("The sum of x and y is "+sum(a,b));