John Delmark Aguilar
Would you like to react to this message? Create an account in a few clicks or log in to continue.
John Delmark Aguilar

Personal Forum
 
HomeSearchLatest imagesRegisterLog in

 

 Scanner Syntax

Go down 
AuthorMessage
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Scanner Syntax Empty
PostSubject: Scanner Syntax   Scanner Syntax Icon_minitimeTue Oct 23, 2012 9:04 pm

The program must start with this import java.util.*; Again it must be before the class name but inside the method code.

What is the difference of the Scanner to BufferedReader Question Question

Scanner uses less code than the BufferedReader.

Code:

Code:
import java.util.*;
Scanner scName = new Scanner(System.in);

Sample Program:

Code:

import java.util.*;
class progName{
    public static void main(String[] args){
    Scanner scnr = new Scanner(System.in);

String stringVar = scnr.nextLine();
int intVar = scnr.nextInt();
Double doubleVar = scnr.nextDouble();
Float floatVar = scnr.nextFloat();
    }
}
Back to top Go down
https://delmark.forumtl.com
 
Scanner Syntax
Back to top 
Page 1 of 1
 Similar topics
-
» BufferedReader Syntax
» Displaying Syntax System.out.print

Permissions in this forum:You cannot reply to topics in this forum
John Delmark Aguilar :: dElmARk Productions :: Java Programs :: Tutorials-
Jump to: