Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-26-2007, 11:21 PM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
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
Sponsored Links
  #2 (permalink)  
Old 07-27-2007, 01:10 AM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
please help
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-27-2007, 03:39 PM
Senior Member
 
Join Date: Dec 2006
Posts: 748
levent is on a distinguished road
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, 08:55 PM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
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
Sponsored Links
Reply


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

vB 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 11:11 AM
Using Scanner class to read int Java Tip Java Tips 0 01-18-2008 01:50 PM
Using Scanner class to read int value Java Tip Java Tips 0 12-03-2007 11:34 AM
Scanner class ajaymenon.k Advanced Java 1 11-26-2007 09:01 AM


All times are GMT +3. The time now is 10:11 AM.


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