Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strings Problem

 
siddu banjapally
Greenhorn
Posts: 13
Chrome Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Try this.

Edit: removed complete solution.

Thanks
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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.


@siddu
Hi and welcome to the JavaRanch!

Try to iterate through the string and check if each character is a number/somethingElse.
 
Vijay Tidake
Ranch Hand
Posts: 148
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wouter Oet,

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

Thanks
 
bhanu chowdary
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@siddu
Welcome to javaranch
 
fred rosenberger
lowercase baba
Bartender
Posts: 12185
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
siddu banjapally
Greenhorn
Posts: 13
Chrome Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THANKS to all
Siddu
 
suryakanta sahoo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic