• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how can i handle multiple exception message ?

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think SubmitBtn is a very bad name for a listener. Convention has it that the name should end “…Listener”.
Why are you taking a char[] from the password field and then converting it to a String? Don't. Validate the char[] only, then fill it with a default character, e.g. Arrays.fill(pwd, '\0'); when you have finished with it.
Why are you setting the text to show a valid password before you have validated it?
Why does your message say anything about nulls? Is it possible for the password to be null at all? Why are you testing for length 0 and later for length < 7?
Don7apos;t throw an Exception and catch ti in the same method. That is simply an inefficient way to write an if‑else.
You can create different messages, but your block of ifs can't cope with a password like HxrTG, which will fail for not having a number, and will never reach the test for < 7 characters.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic