• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception for number >= 0 and > 240  RSS feed

 
Tom Ross
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a program that currently catches the NumberFormatException for the JTextField.getText() command when adding to a string variable. However, I'm trying to create an exception for any values less than or equal to 0 and greater than 240 before adding the converted Double values to an array. Any suggestions?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Ross wrote:I created a program that currently catches the NumberFormatException for the JTextField.getText() command when adding to a string variable. However, I'm trying to create an exception for any values less than or equal to 0 and greater than 240 before adding the converted Double values to an array. Any suggestions?


You mean like this?


 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Ross wrote:However, I'm trying to create an exception for any values less than or equal to 0 and greater than 240 before adding the converted Double values to an array. Any suggestions?

why do you want to create an exception object there? are you going to throw ?

And Welcome to JavaRanch
 
Tom Ross
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I am looking to throw an exception if the value of the double is not high, equal to zero, or negative
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Ross wrote:Yes I am looking to throw an exception if the value of the double is not high, equal to zero, or negative


So are you still having trouble? If so, in what way did my previous post not answer your question?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!