标签:style blog http color java 使用 io 2014
import java.io.Console;
import java.lang.System;
import java.util.*;
/**
* This program demonstrates console input
* @version 1.10 2014-8-5
* @author Administrator
*
*/
public class InputTest {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
// get first input
System.out.print("What is your name?");
String name = in.nextLine();
// get second input
System.out.print("How old are you?");
int age = in.nextInt();
// display output to console
System.out.println("Hello, " + name + ". New year you will be " + (age + 1));
Console cons = System.console();
if(cons != null)
{
System.out.print("User Name:");
String username = cons.readLine();
System.out.print("Password: ");
char[] passwd = cons.readPassword();
}
else
{
System.out.println("Console object is null");
}
}
}
标签:style blog http color java 使用 io 2014
原文地址:http://blog.csdn.net/fantasy_wxe/article/details/38391941