• Post Reply Bookmark Topic Watch Topic
  • New Topic

checking a string for digits  RSS feed

 
Sean Paulson
Ranch Hand
Posts: 87
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok im trying to get this code to work, they (online tutorial) are wanting me to check if a three char string contains a digit, they have only introduced me to .isDigit and .isLetter and .isWhiteSpace.
So why will this not work?
also when i use .isDigit or .isLetter do i have to type character.isDigit or .isLetter or can i put a variable there like "string = passCode;" passCode.isDigit()? i mean its returning a boolean type right so i would have to use hasDigit right(which is my boolean)


ok i think i see why that wouldnt work because im guessing the .isdigit can only check one so substring is checking 3 (i guess) so how about this.

 
Sean Paulson
Ranch Hand
Posts: 87
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i get a error for the character.isDigit

CheckingPasscodes.java:9: cannot find symbol symbol : variable character location: class CheckingPasscodes if (character.isDigit(passCode.charAt(0)) || character.isDigit(passCode.charAt(1)) || character.isDigit(passCode.charAt(2))) {


also i can only change the first if statement. and i would rather not use arrays because they just want me to use what was taught in this lesson ^
 
Knute Snortum
Sheriff
Posts: 4276
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember, Java is cAsE sEnSiTiVe. character is not Character.
 
Sean Paulson
Ranch Hand
Posts: 87
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
? well i have the "c" lower cased. ?
 
Knute Snortum
Sheriff
Posts: 4276
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And is that correct?
 
Sean Paulson
Ranch Hand
Posts: 87
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh never mind you ment its not character its Character thanks lol
 
Sean Paulson
Ranch Hand
Posts: 87
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yup i had it lower cased, i was so frustrated and focused on what else was wrong i did not even think about that. lol plus i wasent sure if i had to use Character or if i could use a variable
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember the conventions. Class names always start with CapitalLetters. Method and variable names use mixedCase.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!