Results 1 to 4 of 4
  1. #1
    geforce is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Throwing exceptions and changing name to a default name

    Okay lets say I have a method called setName() and it needs to follow the regex and it cant be empty, if that statement is false, it throws an exception. Once it's false and throws it's exception I want it to turn into a default name for example like "unknown name" but whenever I do and run it only the error exception pops out, would I need to do something in the setName() part or getName() part? I tryed the getName() already and setName(), don't know what I'm doing wrong.
    Last edited by geforce; 01-28-2012 at 10:26 PM.

  2. #2
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Re: Throwing exceptions and changing name to a default name

    Can You show what You tryed?

    You can have method called getName(), but not class, since getName() is not valid class definition.
    But if You say class getName{}, than it could be class.

  3. #3
    geforce is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Re: Throwing exceptions and changing name to a default name

    It's a method, typo.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Throwing exceptions and changing name to a default name

    Quote Originally Posted by geforce View Post
    Okay lets say I have a method called setName() and it needs to follow the regex
    Please explain: what do you mean by "follow the regex"?

    ... and it cant be empty,...
    Please explain: what can't be empty? The parameter passed? Something returned from the method?

    ... if that statement is false, it throws an exception.
    Please explain: what statement? What do you mean by "is false"?

    ... Once it's false and throws it's exception I want it to turn into a default name for example like "unknown name"
    Please explain: turn what into a default name?

    ... but whenever I do and run it only the error exception pops out, would I need to do something in the setName() part or getName() part? I tryed the getName() already and setName(), don't know what I'm doing wrong.
    You're asking this question as if we already know a bit about your program and your problem -- but we don't. Please ask a complete question, one with all the information necessary to answer it in the first post if possible.

Similar Threads

  1. GUI throwing exceptions
    By pwnedu46 in forum New To Java
    Replies: 3
    Last Post: 06-16-2011, 08:00 PM
  2. Changing Default JDK
    By tabchas in forum NetBeans
    Replies: 0
    Last Post: 04-04-2011, 04:42 AM
  3. Throwing exceptions
    By senorbum in forum New To Java
    Replies: 7
    Last Post: 07-22-2010, 01:57 AM
  4. throwing exceptions in Iterator subclasses
    By hirop35 in forum New To Java
    Replies: 4
    Last Post: 10-15-2009, 09:19 PM
  5. Replies: 4
    Last Post: 08-30-2009, 11:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •