TechieDrill Your World Of Technical Tutorials

Posts Tagged ‘trick’

Java Console Tricks

11.22.2009 · Posted in Java

import java.io.*; class ConsoleDemo { public static void main(String args[]) { String str; Console con; con = System.console(); if(con ==null) return; str = con.readLine(”Enter a string”); con.printf(”Here is your string: %s\n”, str); System.out.println(”Please enter password…”); char cpass[] = con.readPassword(”****************************”); System.out.println(”Your password is : “); for ( int i=0; i<cpass.length; i++) System.out.println(cpass[i]); } } This is a cool java trick. ...