Author |
Message |
wtd
|
Posted: 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
|
|
|
rizzix
|
Posted: Thu Nov 04, 2004 7:42 pm Post subject: (No subject) |
|
|
nice! you can use this to create your own interpreter/compiler. |
|
|
|
|
|
randint
|
Posted: 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
|
Posted: 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
|
Posted: 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 |
|
|
|
|
|
|