I am trying with this code to replace null values in arraylist. I am getting null values in a tag in my xml file. Values in that tag are coming from arraylist. I want to remove null from tag and put nothing in place of it. My code is something like this:
for(String s:a.getList){
here I setting values in tag by create tag and than appending child nodess using DOM parser.
}
where a=object that contains list
output is like this:
<value>1</value>
<value>2</value>
<value>null</value>
<value>3</value>
<value>4</value>
<value>null</null>
. . .and so on
Expected output:
<value>1</value>
<value>2</value>
<value/>
<value>3</value>
<value>4</value>
<value/>
null should be removed and tag should look something like this
code I am trying is:
for(String s:a.list){
if(s.equals("null")){
s.replace("null","");
my code;
}
Always getting null pointer exception and don't know if this runs what will be output. Please help..