2 Replies - 273 Views - Last Post: 26 May 2011 - 10:06 PM Rate Topic: -----

#1 LittlePanda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-May 11

Java Question - Name At Least 3 Alphabets

Posted 26 May 2011 - 09:41 PM

Hello everybody,
Another question here to ask.

Here it goes,
I have to ask for the person's name,
And I have to make sure that the person's name is more than 3 alphabets.

String AskName = Keyboard.readString("Enter Name: ");


E.g.
Enter Name: We
*** Invalid, Re-Enter Name: Wee
( Accepted )

Do I have to put it in an array or something?
Sorry, my Java is really bad,
I'm just a Java newbie,
Oh, and I am only allowed to use 1-D array,
Please advise. ^^

Is This A Good Question/Topic? 0
  • +

Replies To: Java Question - Name At Least 3 Alphabets

#2 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7564
  • View blog
  • Posts: 12,688
  • Joined: 19-March 11

Re: Java Question - Name At Least 3 Alphabets

Posted 26 May 2011 - 10:03 PM

For "alphabets" I'm reading "characters". Try String.length() - information is here.

This post has been edited by jon.kiparsky: 26 May 2011 - 10:04 PM

Was This Post Helpful? 0
  • +
  • -

#3 x68zeppelin80x  Icon User is offline

  • D.I.C Addict

Reputation: 129
  • View blog
  • Posts: 576
  • Joined: 07-March 09

Re: Java Question - Name At Least 3 Alphabets

Posted 26 May 2011 - 10:06 PM

View PostLittlePanda, on 26 May 2011 - 10:41 PM, said:

Hello everybody,
Another question here to ask.

Here it goes,
I have to ask for the person's name,
And I have to make sure that the person's name is more than 3 alphabets.

String AskName = Keyboard.readString("Enter Name: ");


E.g.
Enter Name: We
*** Invalid, Re-Enter Name: Wee
( Accepted )

Do I have to put it in an array or something?
Sorry, my Java is really bad,
I'm just a Java newbie,
Oh, and I am only allowed to use 1-D array,
Please advise. ^^


You should try out the java.util.Scanner class

check if 'AskName.length() < 4' if so re-prompt user
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1