Output - System.out - This is an object not a class.
Input - System.in -See the example below
Scanner scan = new Scanner(System.in);
String str = scan.readLine();
Int a = scan.nextInt();
For password from the command prompt java6 introduces a Console class.
Console cons = System.console();
String username = cons.readLine("User name: ");
char[] passwd = cons.readPassword("Password: ");// password is returned as char array for security reasons
printf in java - Java 5 supports printf someehat similar to that of c. It is implemented to provide formated output.
eg double num = 1000.0/3.0;
System.out.printf("%8.2f",num); shows output as 333.33 (padded with 5 spaces from the left)
Well Hello to all the readers of the blog. To start with the very first writeup of the blog i would like to introduce the purpose of the blog. The blog aims at providing in depth and sufficient knowledge of JAVA language. This blog will be beneficial for all those people who are new in professional world and figth with the concept and knowledge world in their early stages.
Total Pageviews
Wednesday, January 19, 2011
Input and Output
Subscribe to:
Post Comments (Atom)
java new version supports password masking but is there any other method in previous version for password masking. do anybody knows any ??
ReplyDelete@Anjani there is no inbuild mechanism provided by java for console to get password from user. Though this can be done by replacing the character which user enters by "*". (This thing happens in mobile phone browsers).You can have a look at the example for the implementation at : Mask Password
ReplyDelete