Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners please send code

Have Programming Question? Ask it here!
 
 
 


chandrasekhar
please send code
2 Answer(s)      5 years and 9 months ago
Posted in : Java Beginners



Advertisement
View Answers

December 18, 2008 at 6:29 AM


Hi friend,

Code to solve the problem :

class StringExampleJava
{
public static void main(String[] args)
{
String str = "AC2E4T45hj789";
for(int i=0;i<str.length();i++)
{
Character c = new Character(str.charAt(i));

String strVar = c.toString();
if((strVar.equals("0")) || (strVar.equals("1")) || (strVar.equals("2")) || (strVar.equals("3")) ||
(strVar.equals("4")) || (strVar.equals("5"))|| (strVar.equals("6"))|| (strVar.equals("7")) || (strVar.equals("8"))
|| (strVar.equals("9")))
{
System.out.print(strVar);
}
else
{
System.out.print(" ");
}

}
}
}


Thanks


December 18, 2008 at 9:50 PM


Hi

String Str="AC2E4T45hj78922sdfg";
System.out.println(Str.replaceAll("[a-z[A-Z]]"," "));


Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com