1. /* 
  2.  *  
  3. 以下的静态方法实现了:把串s中第一个出现的数字的值返回。 
  4. 如果找不到数字,返回-1 
  5.  
  6. 例如: 
  7. s = "abc24us43"  则返回2 
  8. s = "82445adb5"  则返回8 
  9. s = "ab"   则返回-1    
  10.  
  11.  */ 
  12. import java.io.BufferedReader; 
  13. import java.io.IOException; 
  14. import java.io.InputStreamReader; 
  15. public class test3 { 
  16.  
  17.     /** 
  18.      * @param args 
  19.      * @throws IOException  
  20.      */ 
  21.     public static void main(String[] args) throws IOException { 
  22.         // TODO Auto-generated method stub 
  23.         BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in)); 
  24.         String string=bufferedReader.readLine(); 
  25.         System.out.print(getFirstNum(string)); 
  26.          
  27.     } 
  28.     public static int  getFirstNum(String s) { 
  29.         if (s==null||s.length()==0) { 
  30.             return -1
  31.         } 
  32.         char c=s.charAt(0); 
  33.         if (c>='0'&&c<='9') { 
  34.             return Integer.valueOf(""+c); 
  35.         } 
  36.         return getFirstNum(s.substring(1)); 
  37.         //return 0; 
  38.     } 
  39.