Guest User

Untitled

a guest
Jun 12th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public class Employee {
  2. private String username;
  3. **private String password; //mask this field**
  4. private String city;
  5. }
  6.  
  7. public class Employee {
  8. private String username;
  9. private String password;
  10. private String city;
  11.  
  12. @Override
  13. public String toString() {
  14. return "username=" + username + " city=" + city;
  15.  
  16. }
  17.  
  18. public static void main(String[] args) {
  19. System.out.println(new Employee().toString());
  20. }
  21. }
  22.  
  23. String maskedPassword = s.replaceAll("password=[^&]*", "password=***");
  24.  
  25. public class MaskedString(){
  26. private String maskedString;
  27.  
  28. MaskedString(){
  29. maskedString = "";
  30. }
  31.  
  32. MaskedString(String string){
  33. maskedString = string;
  34. }
  35.  
  36. public String getActualString(){
  37. return maskedString;
  38. }
  39.  
  40. public String setString(String string){
  41. maskedString = string;
  42. }
  43.  
  44. public String toString(){
  45. return "Not the actual string!";
  46. }
  47. }
Add Comment
Please, Sign In to add comment