Me again please a little stuck ere for a question

public void SetValue in (replacementvalue)
if ((replacementvalue >= 0) && (replacmentvalue < limit))
value = replacementvalue
Just a couple of questions id like to ask about this ,
what would happen when the setvalue is called with an illegal value , is this a good solution and also is there any better one , im a little stuck with all this java stuff ,
also what would happen if i changed the (replacementvalue > 0 ) rather than >= 0 ,
also what would happen if I changed the logical operator to a || (or ) one , those this mean it only needs one to be true for the expression to be done ,
ah java is a little hard if you ask me . help appreachiated

what would happen when the setvalue is called with an illegal value nothing would happen, and no its not a good solution really, an exception should be thrown:
if(replacementvalue >= 0 && replacementvalue < limit)
throw new IllegalArgumentException("Bad data");
also what would happen if i changed the (replacementvalue > 0 )
rather than >= 0 ">" means "Greater Than", ">=" means "Greater than or equal to"
also what would happen if I changed the logical operator to a ||
(or ) one those this mean it only needs one to be true for the
expression to be done Yes.

Similar Messages

Maybe you are looking for