chaitu chaitu
asked on
how can i assign one arraylist to another
if(breakBulkHouseModel.get ChargesLis t()!=null)
{
breakBulkHouseModel.getCha rgesList() .addAll(br eakBulkHou seModel.ge tViewCharg esList());
}
else
{
}
how can i assign one arraylist to another if breakBulkHouseModel.getCha rgesList() is null
like breakBulkHouseModel.getCha rgesList() =breakBulkHouseModel.getVi ewChargesL ist();
after that i will do like this
if(breakBulkHouseModel.get ChargesLis t() != null)
{
for(int j=0;j<breakBulkHouseModel. getCharges List().siz e();j++)
{
.......................... .
}
}
{
breakBulkHouseModel.getCha
}
else
{
}
how can i assign one arraylist to another if breakBulkHouseModel.getCha
like breakBulkHouseModel.getCha
after that i will do like this
if(breakBulkHouseModel.get
{
for(int j=0;j<breakBulkHouseModel.
{
..........................
}
}
You can either assign or copy (of which you gave an example). What is the difficulty?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
in some cases breakBulkHouseModel.getCha rgesList() will come null then i want to assign breakBulkHouseModel.getCha rgesList() to breakBulkHouseModel.getVie wChargesLi st() ;
in my application i am doing
breakBulkHouseModel.getCha rgesList() .addAll(br eakBulkHou seModel.ge tViewCharg esList());
if breakBulkHouseModel.getCha rgesList() will come null i am getting nullpointer exception;
at that time i want assign
tChargesList() =ViewChargesList();
in my application i am doing
breakBulkHouseModel.getCha
if breakBulkHouseModel.getCha
at that time i want assign
tChargesList() =ViewChargesList();
ASKER
if(breakBulkHouseModel.get ChargesLis t()!=null)
{
for(Iterator k=breakBulkHouseModel.getC hargesList ().iterato r();k.hasN ext();)
{
HouseDocumentCharges viewCharges = (HouseDocumentCharges)k.ne xt();
if(breakBulkHouseModel.get ViewCharge sList()!=n ull)
{
for(Iterator j=breakBulkHouseModel.getV iewCharges List().ite rator();j. hasNext(); )
{
HouseDocumentCharges charges = (HouseDocumentCharges)j.ne xt();
if(charges.chargeId.equals (viewCharg es.chargeI d) || !charges.chargeId.equals(" 045"))
{
j.remove();
continue;
}
}
}
}
if(breakBulkHouseModel.get ChargesLis t() != null && breakBulkHouseModel.getVie wChargesLi st() != null)
breakBulkHouseModel.getCha rgesList() .addAll(br eakBulkHou seModel.ge tViewCharg esList());
}
else
breakBulkHouseModel.getCha rgesList() .addAll(br eakBulkHou seModel.ge tViewCharg esList());
if i am doing like this i am getting nullpointer exception because breakBulkHouseModel.getCha rgesList() comes nulll
at that time i want to assign
breakBulkHouseModel.getCha rgesList() =breakBulkHouseModel.getVi ewChargesL ist();
if(breakBulkHouseModel.get ChargesLis t() != null)
{
for(int j=0;j<breakBulkHouseModel. getCharges List().siz e();j++)
{
houseDocumentCharges =(HouseDocumentCharges)bre akBulkHous eModel.get ChargesLis t().get(j) ;
}
}
{
for(Iterator k=breakBulkHouseModel.getC
{
HouseDocumentCharges viewCharges = (HouseDocumentCharges)k.ne
if(breakBulkHouseModel.get
{
for(Iterator j=breakBulkHouseModel.getV
{
HouseDocumentCharges charges = (HouseDocumentCharges)j.ne
if(charges.chargeId.equals
{
j.remove();
continue;
}
}
}
}
if(breakBulkHouseModel.get
breakBulkHouseModel.getCha
}
else
breakBulkHouseModel.getCha
if i am doing like this i am getting nullpointer exception because breakBulkHouseModel.getCha
at that time i want to assign
breakBulkHouseModel.getCha
if(breakBulkHouseModel.get
{
for(int j=0;j<breakBulkHouseModel.
{
houseDocumentCharges =(HouseDocumentCharges)bre
}
}
See my code above. You could also simply assign getViewChargesList to 'cl' in the else block if you want
:-)
Actually you can do just
cl = new ArrayList(breakBulkHouseMo del.getVie wChargesLi st());
Actually you can do just
cl = new ArrayList(breakBulkHouseMo