aspose file tools*
The moose likes Beginning Java and the fly likes Cannot find symbol error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot find symbol error message" Watch "Cannot find symbol error message" New topic
Author

Cannot find symbol error message

Onyeabo Orji
Greenhorn

Joined: Sep 12, 2010
Posts: 3
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jul 20, 2008
Posts: 83
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


SCJP 1.5 | SCWCD 5 | SCJP 6.0
[url]http://a2zjava.webs.com[/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
http://soniyaahuja.webs.com
Onyeabo Orji
Greenhorn

Joined: Sep 12, 2010
Posts: 3
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

Joined: Oct 13, 2005
Posts: 38865
    
  23
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

Joined: Oct 13, 2005
Posts: 38865
    
  23
And I see David Newton has already given you the answer.
Onyeabo Orji
Greenhorn

Joined: Sep 12, 2010
Posts: 3
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

Joined: Sep 29, 2008
Posts: 12617

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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot find symbol error message