Results 1 to 5 of 5
- 11-04-2010, 11:48 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 20
- Rep Power
- 0
Check if a string contains characters entered in a array
I would determine if a string entered by the user contains only characters in the table lettresAleatoires. If a letter is different, it rejects what he wrote and asked to enter another string. Here's what I wrote until now, the code in the method verifierSiValide () is missing and this is the method I want to audit.
Java Code:private final static char[] lettresAleatoires = { 'R', 'B', 'O', 'V', 'J', 'F', 'I', 'N' }; private static void demanderCombinaison() throws IOException { do { System.out.println("Entrez votre combinaison pour l'essai " + essai + " <enter> pour arrêter"); CombinaisonEntree = r.readLine(); } while (CombinaisonEntree.length() != 4); } private static void verifierSiValide() { }
- 11-05-2010, 12:07 AM #2
Member
- Join Date
- Oct 2010
- Posts
- 94
- Rep Power
- 0
In verifierSiValide you could go through every character in the entered line and check whether it is present in lettresAleatoires.
I don't think lettresAleatoires should be an array of chars. You could use a String in stead.
Cheers,
ErikI'm new to Java but I like to help where ever I can. :)
-
- 11-05-2010, 08:42 AM #4
Member
- Join Date
- Oct 2010
- Posts
- 94
- Rep Power
- 0
- 11-05-2010, 10:43 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
How to test whether the entered value is numeric or it contains some characters.
By renu in forum New To JavaReplies: 13Last Post: 09-23-2010, 07:21 PM -
check string inside string
By alacn in forum New To JavaReplies: 8Last Post: 07-07-2010, 12:52 PM -
How to check whether the string contains only the specified characters ????
By j_kathiresan in forum New To JavaReplies: 1Last Post: 04-30-2010, 03:21 PM -
Creating Array of Characters From a String
By ngc0202 in forum New To JavaReplies: 6Last Post: 07-30-2009, 07:30 AM -
[SOLVED] How to check what type of value entered in text field
By Renegade85 in forum New To JavaReplies: 2Last Post: 04-28-2008, 10:26 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks