• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot find symbol error message

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic