By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

How to display null elements in arraylist as 0(zeros)?

P: 24
I am preparing an application which takes information and displays it..
I used arraylist to get elements from database..

Expand|Select|Wrap|Line Numbers
  1. ArrayList<String> noD = new ArrayList<String>();
In above line noD=No. of Days..

This is how I get data
Expand|Select|Wrap|Line Numbers
  1. noD.add(rs1.getString("noD"));
using for loop i display the data as
Expand|Select|Wrap|Line Numbers
  1. noD.get(loop variable)

There are certain noD in database which has no value and it is displayed as null and others as it is....

Now I want to display these null elements as 0... how to achieve that....
May 23 '13 #1
Share this Question
Share on Google+
4 Replies


P: 24
got it....
I figured it out....
May 23 '13 #2

Nepomuk
Expert 2.5K+
P: 3,112
Well done for solving the problem, Shepard. Would you care to share your solution so that others with similar problems can find it in the future?
May 23 '13 #3

P: 24
before displaying the output simply added an if condition which checks for null values and replaces it with 0.
I am a newbie..
It was a newbie doubt..
May 23 '13 #4

Nepomuk
Expert 2.5K+
P: 3,112
It may be a newbie question, but we all start as newbies. So thanks for sharing your solution.
May 23 '13 #5

Post your reply

Sign in to post your reply or Sign up for a free account.