Andrej Buday Andrej Buday - 11 months ago 45
Java Question

Radnom cannot be resolved to a type - Typo error in Java itself

I have retyped LinkedIn learning material for Java fortune telling program.

Obviously I do not have typo in random keywords but Java shows runtime error about Radnom. Can anybody give me a clue what can cause this error?


Exception in thread "main" java.lang.Error: Unresolved compilation

Radnom cannot be resolved to a type

Type mismatch: cannot convert from String to ArrayList

Syntax error, insert "Finally" to complete TryStatement at customPrograms.FortuneTeller.main(

Image proof:

enter image description here

My Code:

package customPrograms;
import java.util.Random;
import java.util.Scanner;
import java.util.ArrayList;

public class FortuneTeller {

public static void main(String[] args) {
File inputFile = new File("answers.txt");
ArrayList<String> answers = new ArrayList<String>();
String answer, response = "y";
Random rand = new Random();
try {
Scanner input = new Scanner(inputFile);
answer = input.nextLine();
} catch(Exception e) {
System.out.println("The input file \"answers.txt\" was not found." );

Scanner in = new Scanner(;
while (response.equalsIgnoreCase("y"))
System.out.println("The fortune teller is ready for you \n"
+ "Please think about question in your mind \n and hit enter for your reply");
System.out.println("The fortune teller says: \n" + answers.get(rand.nextInt(answers.size())) +
System.out.println("Do you have another question? (y/n)");
response = in.nextLine();

Answer Source

As long as 15th line is:

Random rand = new Random();

I think I figured out what is going on in your project: you don't have the .class files synced with .java sources.


In Project menu:

select Build project option.

After mark Build Automatically to keep files synced.

enter image description here