Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java 5.0 and the Scanner class
Index -> Java
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Thu Nov 04, 2004 5:05 pm   Post subject: Java 5.0 and the Scanner class

Don't have time to say much right now, but go take a look at Scanner.
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Thu Nov 04, 2004 7:42 pm   Post subject: (No subject)

nice! you can use this to create your own interpreter/compiler.
randint




PostPosted: Sat Oct 15, 2011 8:35 am   Post subject: RE:Java 5.0 and the Scanner class

I think that the Scanner class is out-of-date, we now use this:
import java.io.*;
public class <class name>
{
public static void main (String args[]) throws IOException
{
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
System.out.print ("Enter text: ");
String text = br.readLine();
//code to make use of the variable "text"
}
}
DemonWasp




PostPosted: Sat Oct 15, 2011 10:15 am   Post subject: RE:Java 5.0 and the Scanner class

Two things:

1. Scanner is not out-of-date; depending on application you may use either the method you list or Scanner or some combination or variation.

2. You resurrected a thread that's almost 7 years old. Please try to post only in recent threads.
c0505674




PostPosted: Fri Dec 12, 2014 2:30 pm   Post subject: RE:Java 5.0 and the Scanner class

import java.util.Scanner;
/*you must use this import statement to use the scanner class*/

Scanner scan = new Scanner(System.in);
/*this is the syntax of how to instantiate a new scanner. you can substitute the "scan" for the variable of your choosing*/

kb.nextLine();
//reads in a String from the keyboard

kb.nextInt();
//reads in an int (integer) from the keyboard

kn.nextDouble();
//reads in a double from the keyboard

kb.nextBoolean();
//reads in a boolean from the keyboard

kb.nextLong();
//reads in a long from the keyboard
Display posts from previous:   
   Index -> Java
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: