Jremy
Jremy

Reputation: 83

Using Java, how do I accept and categorize a phrase that has numbers and letters in user input?

I'm writing an application that I'd like to be able to accept and hold the user's input of a combination of numbers and letters (06712A1, for instance), and then input that info into an array. I assume I can't use Integer since there are letters inside it. How do I do this?

Upvotes: 0

Views: 78

Answers (3)

WW.
WW.

Reputation: 24281

You need to use the String datatype to represent a sequence of characters.

This tutorial on Strings in java might be useful.

Upvotes: 1

SJuan76
SJuan76

Reputation: 24885

Your question is ambiguous.

I assume you mean that you want to use that String as an index to another object. In that case, search for the java.util.Map subclass that suits you.

Upvotes: 0

Savvas Dalkitsis
Savvas Dalkitsis

Reputation: 11592

Use a String and then validate it by examining all the letters it contains.

What do you mean by "input that info into an array"? Put each character into a separate position in an array?

Upvotes: 1

Related Questions