chaitu chaitu
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;
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;
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.
ASKER
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 HousedocumentchargesIterat or = yourArrayList.Iterator();
while(Housedocumentcharges Iterator.h asNext()){
Housedocumentcharges housedocumentcharges= (Housedocumentcharges )usedocumentchargesIterato r.next()
if(housedocumentcharges.ge tBillamoun t==0){
throw new OwnException;
}
}
return true
}
public boolean check() throws OwnException{
Iterator HousedocumentchargesIterat
while(Housedocumentcharges
Housedocumentcharges housedocumentcharges= (Housedocumentcharges )usedocumentchargesIterato
if(housedocumentcharges.ge
throw new OwnException;
}
}
return true
}
ASKER
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
if all the 10 chargeid's have no billamount's at that time only i want throw the exception
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What do you mean "throw message"?
You talking about exceptions?