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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shepard
    New Member
    • Feb 2013
    • 24

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

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

    Code:
    ArrayList<String> noD = new ArrayList<String>();
    In above line noD=No. of Days..

    This is how I get data
    Code:
    noD.add(rs1.getString("noD"));
    using for loop i display the data as
    Code:
    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....
  • Shepard
    New Member
    • Feb 2013
    • 24

    #2
    got it....
    I figured it out....

    Comment

    • Nepomuk
      Recognized Expert Specialist
      • Aug 2007
      • 3111

      #3
      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?

      Comment

      • Shepard
        New Member
        • Feb 2013
        • 24

        #4
        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..

        Comment

        • Nepomuk
          Recognized Expert Specialist
          • Aug 2007
          • 3111

          #5
          It may be a newbie question, but we all start as newbies. So thanks for sharing your solution.

          Comment

          Working...