• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

readLine() problem

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I typed in a ready-made class from a textbook and can not get it to compile. In part it reads:

import java.io.*;
public class <name> {
....
BufferedReader is = new BufferedReader(
new InputStreamReader(System.in));
inputLine = is.readLine();
....
}

When I try to javac it, I get "canot find symbol" on readLine.

Any ideas?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the *exact* error message?

Is the variable inputLine declared and in scope?
 
Will Hoskins
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
inputLine is declared as a String, then there is a "try" block including the attempted read. The code (GameHelper.java) is copied from page 112 of Head First Java Feb. 2005 edition.

The error messages follow. (Presumably the second will go away when the first is resolved). The pointers (before the lines are collapsed to the left margin) are at "readLine" on the first error, and "." on the second.

C:\jdk6\test2008>javac GameHelper.java
GameHelper.java:9: cannot find symbol
symbol : method readLine()
location: class GameHelper
inputLine = is(readLine());
^
GameHelper.java:10: cannot find symbol
symbol : variable length
location: class java.lang.String
if (inputLine.length == 0) return null;
^
2 errors

[ February 10, 2008: Message edited by: Will Hoskins ]
[ February 10, 2008: Message edited by: Will Hoskins ]
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

inputLine = is(readLine());


This does not match the code you originally posted. Please be sure to accurately post your code. Otherwise, time is wasted chasing red herrings.
 
Will Hoskins
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:

This does not match the code you originally posted. Please be sure to accurately post your code. Otherwise, time is wasted chasing red herrings.



Bonk! (I could have had a V8.) Thank you much. The problem is solved.
 
reply
    Bookmark Topic Watch Topic
  • New Topic