Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-26-2007, 10:21 PM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Rep Power: 0
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
Default JDK 5.0 Scanner Class
Hey, I'm new to this forum, as well as Java. I know that JDK 5.0 has a scanner class for detecting keyboard input as chars, ints, and Strings.
I am using Eclipse, and I created a new Java project with JRE 1.5.0_06.
I updated the JDK with NetBeans, so I am sure I am up-to-date.

I created a simple program in Eclipse which used Input. So the program automatically imported java.util.Scanner. And I wrote my code:
Scanner keyboard = new Scanner(System.in);
char in = keyboard.nextChar();

Everything is recognized but nextChar();
Please help me, because I really want to learn Java. I will try to help people with their problems and such. I will be an ective member of this forum!

Thank you for all you help, time and support!
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-27-2007, 12:10 AM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Rep Power: 0
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
Default
please help
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-27-2007, 02:39 PM
levent
Guest
 
Posts: n/a
Default
Quote:
I am using Eclipse, and I created a new Java project with JRE 1.5.0_06.
I updated the JDK with NetBeans, so I am sure I am up-to-date.
Make sure that your project uses Java 5.0. Projects has their own specs and that project may still point to an older version of Java.

and what is the exact error?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-27-2007, 07:55 PM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Rep Power: 0
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
Default
The error is that it just won't compile. It will show my text underlined in red. I was asking one of my friends, and he informed me that there is no char scanner class, just Ints and Strings. Is this correct for a String scanner :

Scanner key = new Scanner(System.in);
String s = key.next();

and Int is


Scanner key = new Scanner(System.in);
int i = key.nextInt();

Thank you for helping me out!
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting tokens using Scanner class Java Tip Java Tips 0 02-05-2008 10:11 AM
Using Scanner class to read int Java Tip Java Tips 0 01-18-2008 12:50 PM
Using Scanner class to read int value Java Tip Java Tips 0 12-03-2007 10:34 AM
Scanner class ajaymenon.k Advanced Java 1 11-26-2007 08:01 AM


All times are GMT +2. The time now is 03:40 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org