Results 1 to 4 of 4
- 01-28-2012, 10:22 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 12
- Rep Power
- 0
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.
- 01-28-2012, 10:32 PM #2
Senior Member
- Join Date
- Jan 2012
- Posts
- 210
- Rep Power
- 2
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.
- 01-28-2012, 10:37 PM #3
Member
- Join Date
- Jan 2012
- Posts
- 12
- Rep Power
- 0
Re: Throwing exceptions and changing name to a default name
It's a method, typo.
-
Re: Throwing exceptions and changing name to a default name
Please explain: what do you mean by "follow the regex"?
Please explain: what can't be empty? The parameter passed? Something returned from the method?... and it cant be empty,...
Please explain: what statement? What do you mean by "is false"?... if that statement is false, it throws an exception.
Please explain: turn what into a default name?... Once it's false and throws it's exception I want it to turn into a default name for example like "unknown name"
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.... 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.
Similar Threads
-
GUI throwing exceptions
By pwnedu46 in forum New To JavaReplies: 3Last Post: 06-16-2011, 08:00 PM -
Changing Default JDK
By tabchas in forum NetBeansReplies: 0Last Post: 04-04-2011, 04:42 AM -
Throwing exceptions
By senorbum in forum New To JavaReplies: 7Last Post: 07-22-2010, 01:57 AM -
throwing exceptions in Iterator subclasses
By hirop35 in forum New To JavaReplies: 4Last Post: 10-15-2009, 09:19 PM -
Database Project keeps throwing Exceptions.
By Loop in forum JDBCReplies: 4Last Post: 08-30-2009, 11:22 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks