File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Basic Java Problem....HELP!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Basic Java Problem....HELP!!!!" Watch "Basic Java Problem....HELP!!!!" New topic

Basic Java Problem....HELP!!!!

Steve Jensen
Ranch Hand

Joined: Sep 23, 2002
Posts: 126
Hi there folks.
I'm using JBuilder 6 Enterprise edition.
I'm trying to compile the following code:-

class InputDemo {
public static void main(String args[]) {
try {
// Input a single character
System.out.println("Type a character:");
char ch = (char);
System.out.println("You entered: " + ch);
// Throw out new line
while (ch != '/n')
ch = (char);
// Input a string
System.out.println("Type a string:");
StringBuffer s = new StringBuffer();
while ((ch = (char) != '/n')
System.out.println("You entered: " + s);
} catch (IOException e) {
System.out.println("Input error detected");

But when i try and compile this, i get the following error messages:-
"": Error #: 106 : unclosed character literal at line 11, column 18"
"": Error #: 106 : unclosed character literal at line 16, column 48

Line 11 is - while (ch != '/n')
Line 16 is -
while ((ch = (char) != '/n')
Does anybody know why i'm getting these erors??

Any help would be GREATLY appreciated

John Bonham was stronger, but Keith Moon was faster.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
I think you want '\n' , not '/n' .

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Steve Jensen
Ranch Hand

Joined: Sep 23, 2002
Posts: 126
Works fine now!
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Please change your name to be compliant with JavaRanch's naming policy.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.

"JavaRanch, where the deer and the Certified play" - David O'Meara
jQuery in Action, 3rd edition
subject: Basic Java Problem....HELP!!!!
jQuery in Action, 3rd edition