This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Strings Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Strings Problem" Watch "Strings Problem" New topic

Strings Problem

siddu banjapally

Joined: Aug 16, 2011
Posts: 13

Hi friends..
I have one doubt that is, I have one string as following

String s="a1b2c3 dd4f5g10h11z";

then how can I print only alphabets or numbers only??
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146


Try this.

Edit: removed complete solution.


The important thing is not to stop questioning.Curiosity has its own reason for existing.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

@Vijay: I've removed your complete solution. See the forum description:
We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.

Hi and welcome to the JavaRanch!

Try to iterate through the string and check if each character is a number/somethingElse.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146

Hi Wouter Oet,

Thanks for reminding me the rule. Onward I will follow it.

bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
Welcome to javaranch
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11920

if you didn't have a computer, how would you do it with pencil and paper? explain step by step what you would do.

Once you have that (and I literally mean for you to write it down), it's easy to code.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
siddu banjapally

Joined: Aug 16, 2011
Posts: 13

THANKS to all
suryakanta sahoo

Joined: Aug 20, 2011
Posts: 5
I agree. Here's the link:
subject: Strings Problem
It's not a secret anymore!