string to char to string to int
<p>Basically, what this code does is getting a number in any length from the user and sends it back to the user in a digit per digit form plus the sum of all the digits on the given number(e.g. 1234= 1, 2, 3, 4. sum=10). However, I can't make it work on a negative number. </p>

<pre><code>    Scanner s= new Scanner(System.in);

    String num= s.nextLine();

    char arr[]= new char[num.length()];
    int numsarray[]= new int[num.length()];
    String number[]= new String[num.length()];
    int sum=0;

    for(int i=0; i&lt;num.length();i++)
    {
        arr[i]=num.charAt(i);
        System.out.println(arr[i]);

        number[i]=Character.toString(arr[i]);

        numsarray[i]=Integer.parseInt(number[i]);
    }

    for(int i=0;i&lt;num.length();i++)
    {   
        sum+=numsarray[i];
    }
    System.out.println("Sum:"+sum);
</code></pre>
