I have a public class
where I write the methods and the main
from which I instancio to solve the exercises / problems.
I wish to instantiate the following method:
public class metodos {
public void espositivo(int a) {
if (a>0) {
System.out.println("El numero es POSITIVO");
}
else{
System.out.println("El numero es NEGATIVO");
}
}
}
This is my main:
import java.util.Scanner;
public class principal {
public static void main (String [] args) {
metodos op=new metodos();
Scanner leer= new Scanner(System.in);
int a=0;
System.out.println("Ejercicio 2.1");
System.out.println("");
System.out.println("Ingrese un numero para saber si es positivo o no");
a=leer.nextInt();
//posOneg=op.espositivo(a);
}
}
The error appears in the commented line.