repository.grepcode.com$java$root@jdk$openjdk@6-b14
repository.grepcode.com$java$root@jdk$openjdk@6-b14@java$lang$StringIndexOutOfBoundsException.java
file
oh
o
[]
I'm pretty new to programming and I'm getting a error which I'm sure is a easy fix for more experienced people.
Here is what I have:
import java.io.*;
import java.util.Scanner;
public class ReadNamesFile
{
public static void main(String[] args) throws IOException {
// make the names.csv comma-separated-values file available for reading
FileReader f = n...
I wrote this little function just for practice, but an exception ("String index out of range: 29") is thrown and I don't know why...
(I know this isn't the best way to write this function and can I use regular expressions.)
This is the code:
public String retString(String x)
{
int j=0;
int i=0;
StringBuffer y = new StringBuffer(x);
try
{
while ( y.charAt(i) != '\0' )
...
Thrown by
String methods to indicate that an index
is either negative or greater than the size of the string. For
some methods such as the charAt method, this exception also is
thrown when the index is equal to the size of the string.
Constructs a
StringIndexOutOfBoundsException with no
detail message.
Constructs a
StringIndexOutOfBoundsException with
the specified detail message.
- Parameters:
s the detail message.
Constructs a new
StringIndexOutOfBoundsException
class with an argument indicating the illegal index.
- Parameters:
index the illegal index.
super("String index out of range: " + index);