Write a program to accept number from command line and display sum of digits in a number by using recursive funcion
<p>I have written the code but it displays Stackoverflowerror message.</p>

<pre><code>class Sum
{
     int ans=0,temp,temp2;
     int  getsum(int no)
     {
          if(no&gt;0)
          {
              temp=no % 10;
              ans=ans + temp;
              getsum(no/10); 
          }
          else
          {
              return ans;
          }
     }
}


class recsum
{
     public static void main(String args[])
     {
          Sum s=new Sum();
          int no,len;
          len=args.length;

           if(len==0)
           {
               System.out.println("No argruments are given ! ");
           }
           else
           {
               no=Integer.valueOf(args[0]).intValue();
               System.out.println("Sum of digits= " + s.getsum(no));
           }
     }
}
</code></pre>
