Sunday 12 July 2009

A sample of how to take data using the Scanner method

import java.util.Scanner;// Takes IMPORT dialog and IMPORTS the "Scanner" class
public class scannertest {
public static void main(String args[]) {
Scanner x = new Scanner(System.in);
// This is where you created a new Scanner named x and said that its going to scan the System inputs. That is anything you type in the keyboard.
int y = x.nextInt();
//In this statement you are declaring a variable y and assigning the value of the next integer x(The scanner) is scanning.
//And that's it for the basic Scanner method of taking input. there are a lot more but i don't know much yet.
//Make the rest of the program now.

No comments:

Post a Comment