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.

292 questions
2
votes
2 answers

Is there any easier way to set integer for string characters?

I am making converter which converts random string to numbers fancy way. But I was wondering is there easier way to do this: package codec; import javax.swing.JFrame; public final class Codec extends JFrame { public static void…
Pomper
  • 23
  • 2
2
votes
4 answers

How to read special characters in a string in java

I'm given a String & I need to find whether it contains any special character or not? I tried using charAt() and ASCII values.But it didn't work.Someone please help.Thanks in advance. for(int i=0;i
Darpanjbora
  • 163
  • 3
  • 13
2
votes
4 answers

String with 1000 digits, find the biggest 5 digits without an array

I know my code can be simpler and more efficient... My code is supposed to grab the biggest set of 5 digits. It works, except it only is grabbing 3 digits, what would i need to modify to change that? public class thousandDigits { public…
Frank
  • 137
  • 9
2
votes
2 answers

Verifying a String for Numbers and Periods/Decimals

I have this short snippet of code where I have to check a string to see if it contains integers and possibly a decimal. The string is an amount of money (12.34) so as well it can not go past the fourth index. My question is I'm being told to use…
TGen
  • 21
  • 1
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
  • 2
  • 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
  • 914
  • 2
  • 12
  • 30
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: