I am facing this problem, I have no errors in my code. Here is the code .Please remember I am writing java in android studio because I am working on app development.
practice.java
package com.example.javastart;
import java.util.Scanner;
public class practice {
public static void main(String[] args) {
System.out.println("Taking Input");
Scanner sc = new Scanner(System.in);
System.out.println("Enter Number for Table ");
int a = sc.nextInt();
for (int i = 1; i <= 10; i++) {
int total = a * i;
System.out.println(a + " * "+ i + " = "+ total);
}
}
}
Here's some error
Task :javastart:practice.main() FAILED
Taking Input
Enter Number for Table
Exception in thread "main" java.util.NoSuchElementException
at java.base/java.util.Scanner.throwFor(Scanner.java:937)
at java.base/java.util.Scanner.next(Scanner.java:1594)
at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
at com.example.javastart.practice.main(practice.java:9)
Execution failed for task ':javastart:practice.main()'.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.