Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot find symbol error message

 
Onyeabo Orji
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am new to Java and I have written two java classes. The first class will accept an unconstrained array and then output the even numbers in the array. the first class compiled without error while the application class show the following error message which I cannot resolve:

DriverUnArray.java:19:cannot find symbol
symbol: method readline()
location: class java.io.BufferedReader
EvenNumbers = new Interger(KeyboardInput.readline()).intValue();

See the codes below:

UnArrays Class:

//
//
//
//
import java.io.*;
import java.awt.* ;
import java.lang.*;
import java.util.Formatter;



public class UnArrays{

int length;
final int lowerBound=0;
int commaFlag;

int[] ranNumbers;


public static BufferedReader KeyboardInput = new BufferedReader(new InputStreamReader(System.in));

public UnArrays(int size){
length = size;
ranNumbers = new int[length];
}

public void InputRanNumbers() throws IOException {

int index = lowerBound;

System.out.print("Random Numbers {" +ranNumbers[0]);
while (index == ranNumbers.length){
System.out.print("," + ranNumbers[index]);

index++;
}
System.out.print("}\n");

}

public void EvenNumbers(){
int index; commaFlag = 1;
System.out.print("Even Numbers{");
for(index = lowerBound; index < ranNumbers.length; index++){
if(ranNumbers[index]%2==0){
if (commaFlag==0){
System.out.print("," + ranNumbers[index]);

}
else {
System.out.print(ranNumbers[index]);


}

}


}
}
}

DriverUnArray:

import java.io.*;
import java.awt.* ;
import java.lang.*;
import java.util.Formatter;

public class DriverUnArray{

public static BufferedReader KeyboardInput= new BufferedReader(new InputStreamReader(System.in));

public static void main(String[] args)
{
int EvenNumbers;

System.out.println("Input Random Numbers");
EvenNumbers = new Integer(KeyboardInput.readline()).intValue();
UnArrays newUnArray = new UnArrays(EvenNumbers);
newUnArray.InputRanNumbers();
newUnArray.EvenNumbers();

}


}

Thanks.

Oochi
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch! Please UseCodeTags when posting code or configuration; unformatted code is unnecessarily difficult to read.

Java is case-sensitive: readline != readLine.
 
Soniya Ahuja
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Onyeabo welcome to Java Ranch! Try to read the error messages - most of the compiler messages are self explanatory

As pointed out by David - readLine is not similar to readline and hence your compiler complains that the method readline cannot be found
 
Onyeabo Orji
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your prompt response. I have tried to read the error messages and rechecked and could not find anyone that apply to it. ther might be something I am overlooking which is why Ihave inserted my codes.

Thanks.

Oochi
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you have overlooked something. Read the names of the BufferedReader methods very very carefully. Look at the letter after "d" and before "i". Very carefully.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I see David Newton has already given you the answer.
 
Onyeabo Orji
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gents,
Thanks you so much. The issues were resolved and the progam compiled. But when I entered the following random digits : 1 22 3 34 43 71 17 66, I goth the following error messages:
Exception in thread “main” java.lang.NumberFormatException: For input string: “1 22 4 3 34 45 71 17 66”
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown source)
at java.lang.Integer.<init>(Unknown source)
at DriverUnArray.(DriverUnArray:18)

What could be my mistake.

Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because that's not a number.

It was difficult to even find where the input is taken in your code because you didn't UseCodeTags. Of you want people to spend their time helping you, it's important to make it easy for them. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic