Questions tagged [charat]

The charAt() method is used to provide a single character by its index within a string.

The charAt() method is used to provide a single character by its index within a string.

261 questions
2
votes
3 answers

Java charAt() String index out of range: 5

I am trying to figure out "what 5-digit number when multiplied by 4 gives you its reverse?" using this code but I get error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 5 at…
Vayelin
  • 75
  • 1
  • 1
  • 10
2
votes
2 answers

charAt() and Math.pow()

Background: I am making a simple base converter for a class assignment. I am fairly close to completion but need to tidy up the conversion algorithm to convert the user inputted value (in a given base) to a base 10 value. Attempt: import…
jclark754
  • 684
  • 1
  • 7
  • 25
2
votes
5 answers

IndexOutOfBounds Exception Java String Class charAt Method

Method CharAt of the Java String class throws a StringIndexOutOfBoundsException. But the Java API documentation says it throws an IndexOutOfBoundsException. I know that StringIndexOutOfBoundsException is a subclass of IndexOutOfBoundsException. But…
hohum
  • 21
  • 1
  • 2
2
votes
3 answers

RegExp for current character JavaScript

I'm trying to validate a character to make sure it's a letter (not a number, symbol, etc.) BEFORE it's allowed to be entered into the form field. How can I do that with JavaScript? Here is something I tried: