String to asterisk, masking password

前端 未结 4 1376
Happy的楠姐
Happy的楠姐 2020-12-21 15:53

I\'m creating this simple login code for an ATM machine. You enter username and password and you logs in, that works just great. Since I\'m not connecting to a database or a

4条回答
  •  心在旅途
    2020-12-21 16:08

    There's a special method Console.readPassword() for doing this, introduced in Java 6. You obviously couldn't run code like this on a real ATM, though! Swing has JPasswordField which lets you do this kind of masking in a GUI, and one could imagine a Swing-based ATM window.

提交回复
热议问题