Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Utils.java

Go to the documentation of this file.
00001 package net.threebit.utils.sosc ; 
00002 
00010 public class Utils
00011 {
00019     public static int[] toDigits(final String val)
00020     {
00021         int digitArray[] = new int[val.length()];
00022 
00023         for(int i = 0; i < val.length(); i++)
00024         {
00025             digitArray[i] = val.charAt(i) - '0';
00026         }
00027 
00028        return digitArray;
00029     }
00030 
00044     public static int add(final int val)
00045     {
00046         int sum;
00047 
00048         sum = val;
00049 
00050         while(sum > 9)
00051         {
00052             sum = (sum / 10) + (sum % 10);
00053         }
00054         
00055         return sum;
00056     }
00057     
00058     /* converts a number into an array of its digits. */
00059     public static int[] toDigits(final int val)
00060     {
00061         return toDigits(Integer.toString(val));
00062     }   
00063 }
00064 
00065 
00066 

Generated on Mon Jul 14 17:19:20 2003 for SOSC by doxygen1.2.15