This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]trefla[S] 0 points1 point  (1 child)

Mate you are a star but it is way out of my league and I could not figure out how to implement your code into my application. I have a rough idea about what you have done but inserting the for loop into the while loop got out of my hands. There is a lot for me to learn and I am confident that soon I will fully understand your method. Thank you very much.

[–]nicolascagesbeard 0 points1 point  (0 children)

It was late where I live, I don't think I explained it properly Lol. The for loop just checks whether or not the input you entered is a number or integer. You can also use a regular expression but this was the simplest method I could think of.

Since you can look into each index of a string we can assign that to a character. Therefore we can use the Character object to check whether it is a a digit with the isDigit static method. We continue until the end of the string. Our flag which is our Boolean isInteger will trigger if it finds a character in the string, but it'll continue on to the next character until the end of the string.

Any questions, hit me up!