-3

So, I am studying Systems Engineering, and in Into to coding, I was asked to do this, but I am getting an error message that in my mind makes no sense(TBH I barely understood the coding class, I have been working in IT for the past 7 years and have never needed coding U.U )

My Java code is this:

public class Reto {
    public String suma (int valor1, int valor2){
        int resultado = valor1 + valor2;
        return "El resultado es: " + resultado;
     }
    public static void main(String[] args) {
        suma(10,5);
    }
}

Screenshot of my code

And the error message is the following:

Syntax error on token "++", * expected before this token

And if I try to run it without debugging it is:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: Cannot make a static reference to the non-static method suma(int, int) from the type Reto

at Reto.main(Reto.java:7)
Charly
  • 3

0 Answers0