author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/
Import Java. io. console; public class consolelogin {public static void main (string Arg []) {console con; con = system. console (); If (con = NULL) {system. out. println ("no console available. "); return;} string name = con. readline ("name:"); char PW [] = con. readpassword ("Password:"); string Password = new string (PW); system. out. println ("the login name is" + name + "and the pass word is" + password );}} ================================== import Java. io. console; public class consoleoutput {public static void main (string Arg []) {console con; con = system. console (); If (con = NULL) {system. out. println ("no console available. "); return;} int value = 31520; con. printf ("The Number % d as hexidecimal is % 4x/N", value, value) ;}note that the Read and Write methods of the console class are synchronized, and the console may not exist (of course, if you use cmd or shell, it is recommended that you use flush to refresh the display .)
Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/