Hello...can someone just give me a hint or steps how to trap numbers in String Like in names.I have to make my project in java with traping numbers in names..

Recommended Answers

All 2 Replies

What do you mean by "trap" numbers?

Question is a little vague, but I think you mean:

int x=5;
String y=""+x;

So y is "5"

To reverse this, you could grab the character...

int x=y.charAt(0);

then subtract 48, but that assumes you have a digit 0-9 in the first place.

Much better is:

int x=Integer.parseInt("5");

Hope that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.