Link to home
Start Free TrialLog in
Avatar of chaitu chaitu
chaitu chaituFlag for India

asked on

how to throw message in this senario

in the arraylist i have chargeid's and their corresponding billamount;

045--0
162--999
225--900

for above case some charges has billamount then  i dont want to throw message;

 if any chargeid's doesn't have billamount at that time only i want to throw message at client side;
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

>>  i dont want to throw message;

What do you mean "throw message"?

You talking about exceptions?
Avatar of chaitu chaitu

ASKER

yesss
It would better to use HashMap with chargeId's as key and billamount as values so that in your case you can just check if that particular chargeId key exist..if it doesn't then throw the message if it exists get the values of the key if the value is zero then also throw the message.
 
i didnt get u;my charge's stored  in arraylist of Housedocumentcharges object
Ok then iterate throw each element and take each object oy type Housedocumentcharges .In the object you might be having some getter methods to get the charge and billamount if billamount is zero for that particular object then throw the message

public boolean check() throws OwnException{
Iterator HousedocumentchargesIterator = yourArrayList.Iterator();
while(HousedocumentchargesIterator.hasNext()){
Housedocumentcharges  housedocumentcharges= (Housedocumentcharges )usedocumentchargesIterator.next()
if(housedocumentcharges.getBillamount==0){
throw new OwnException;
}
}
return true
}
if i have 10 chargeid's and one chargeid will have bill amount at that i dont want to throw a message;

if all the 10 chargeid's have no billamount's at that time only i want throw the exception
ASKER CERTIFIED SOLUTION
Avatar of koppcha
koppcha
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial