Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. public static void main(String args[])
  2. {
  3. String name = null;
  4. String uppercasedName = null;
  5.  
  6. try {
  7. uppercasedName = name.toUpperCase();
  8. }
  9. catch(NullPointerException e)
  10. {
  11. System.out.println("WARNING: O nome do usuário estava nulo, portanto será tratado como desconhecido.");
  12. uppercasedName = "DESCONHECIDO";
  13. }
  14.  
  15. System.out.println("Seja bem-vindo, " + uppercasedName);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement