aspose file tools*
The moose likes Beginning Java and the fly likes BufferedReader issue? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "BufferedReader issue?" Watch "BufferedReader issue?" New topic
Author

BufferedReader issue?

John Uhlig
Greenhorn

Joined: May 12, 2003
Posts: 13
I have written the following code:



menuSelection is a private String member variable.
showMenu () spits out a menu to the console.

When I run the program, I get this:
Main Menu: (enter in either upper or lower case)
AP = Add person
EP = Edit person
DP = Delete person
AT = Add telephone number
ET = Edit telephone number
DT = Delete telephone number
Q = Quit
Enter your choice:
AP
input...AP...
no match

So, it appears that the result of stdin.readLine() is being assigned to the variable menuSelection, since I can print it out. However, I can't figure out why the result of is failing when I clearly typed AP into the console.

Thanks,
John
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245


Be careful - this gets alot of folks. You're really asking if the memory address of menuSelection is the same as the memory address that the compiler assigned to your string. You'll want to do something like:



to check if the strings contain the same value.


<a href="http://forums.hotjoe.com/forums/list.page" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
John Uhlig
Greenhorn

Joined: May 12, 2003
Posts: 13
Duh - a String is an object, not a primitive. (slap on forehead)
Thank you Scott.

John
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BufferedReader issue?
 
Similar Threads
problematic run-time errors
Help with Java program
Java adding infinte strings
trouble with operator
How to accept Multiline conditional input through console in java program....