
-----------------------------------
wtd
Thu Nov 04, 2004 5:05 pm

Java 5.0 and the Scanner class
-----------------------------------
Don't have time to say much right now, but go take a look at [url=http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html]Scanner.

-----------------------------------
rizzix
Thu Nov 04, 2004 7:42 pm


-----------------------------------
nice! you can use this to create your own interpreter/compiler.

-----------------------------------
randint
Sat Oct 15, 2011 8:35 am

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 
{
   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
Sat Oct 15, 2011 10:15 am

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
Fri Dec 12, 2014 2:30 pm

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
