Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*find numbers from the given string.
- for example if string is"face45face56"
- the output must be 4556*/
- import java.util.Scanner;
- class StringFun
- {
- public static void main(String args[])
- {
- Scanner sc=new Scanner(System.in);
- String s=sc.nextLine();
- int i;
- String s2="";
- char ch;
- for(i=0;i<s.length();i++)
- {
- ch=s.charAt(i);
- if(Character.isDigit(ch))
- s2=s2+ch;
- }
- int num=Integer.parseInt(s2);
- System.out.println(s2);
- //now do anything with num
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement