Friday, 18 November 2016

java - Type Scanner was not found



I'm currently reading Blue Pelican Java to learn new things, I'm on lesson 7 that involves learing keyboard input of int, double and strings.




I'm using Ready to program java to run my programs also.
The error im receiving results from



Scanner sc =new Scanner(System.in);


With the error "Type Scanner was not found" and on the second Scanner "A candidate for type Scanner was found. But was invalid and needs to be fixed before this type will compile"



I copied the code directly from the book upgraded my java looked around online and also tried




import java.util.Scanner.*;


with no success can anyone tell me what I'm missing or doing wrong?



import java.io.*;
import java.util.*;

public class Lesson7

{
public static void main(String args[])
{

Scanner sc =new Scanner(System.in);
System.out.println("Enter your integer here");
int i = sc.nextInt();
System.out.println(3*i);

}

}

Answer



Probably, you are not using the correct jdk version. Scanner class is only available in JDK 1.5 or later.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...