In this Java program, I want to input values from the keyboard and check if the variable contains a certain digit.
I'm using contains method to find out if a variable contains a particular digit. There is an error when I write the code. Can someone please explain the error and how to fix it?
The code:
package nested_package;
import java.util.Scanner;
public class Age_prog {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println("a=" + a + "\n" + "b=" + b);
if (a.contains(1)) { // ERROR IN THIS LINE
System.out.println("true");
} else {
System.out.println("false");
}
}
}