java.lang
Class String

java.lang.Object
  extended by java.lang.String

public final class String
extends Object

An immutable string of characters.


Constructor Summary
String(char[] c)
           
String(char[] c, int off, int len)
          Create a String from a character array.
 
Method Summary
 char charAt(int index)
          Return the character at the given index
 boolean equals(Object other)
          Compares the String with an Object
 int hashCode()
           
 int indexOf(int ch)
          Find the index of a character.
 int indexOf(int ch, int fromIndex)
          Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
 int indexOf(String str)
          Finds the location of a string within this string
 int indexOf(String str, int fromIndex)
           
 int lastIndexOf(String str)
           
 int lastIndexOf(String str, int fromIndex)
           
 int length()
          Return the length of the String in characters
 String substring(int start)
           
 String substring(int start, int end)
           
 char[] toCharArray()
          Converts the String into an array of characters
 String toString()
          Returns itself.
static String valueOf(Object aObj)
          Converts an Object to a String
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait
 

Constructor Detail

String

public String(char[] c,
              int off,
              int len)
Create a String from a character array.

Parameters:
c - the character array
off - the offset - usually 0
len - the length of the String - must not be greater than c.length

String

public String(char[] c)
Method Detail

length

public int length()
Return the length of the String in characters

Returns:
the length of the String

charAt

public char charAt(int index)
Return the character at the given index

Returns:
the characters at the given index

indexOf

public int indexOf(int ch)
Find the index of a character.

Parameters:
ch - The character to find.
Returns:
The index of the character. -1 means it wasn't found.

indexOf

public int indexOf(int ch,
                   int fromIndex)
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.

Parameters:
ch - a character (Unicode code point).
fromIndex - the index to start the search from.
Returns:
the index of the first occurrence of the character in the character sequence represented by this object that is greater than or equal to fromIndex, or -1 if the character does not occur.

indexOf

public int indexOf(String str)
Finds the location of a string within this string

Parameters:
str -
Returns:
Index of string location, -1 if string does not exist.

indexOf

public int indexOf(String str,
                   int fromIndex)
Parameters:
str -
fromIndex -
Returns:
Index of string location, -1 if string does not exist.

lastIndexOf

public int lastIndexOf(String str)

lastIndexOf

public int lastIndexOf(String str,
                       int fromIndex)

toCharArray

public char[] toCharArray()
Converts the String into an array of characters

Returns:
the character Array

substring

public String substring(int start)

substring

public String substring(int start,
                        int end)

valueOf

public static String valueOf(Object aObj)
Converts an Object to a String

Returns:
the String that represents the object

toString

public String toString()
Returns itself.

Overrides:
toString in class Object
Returns:
the String itself

equals

public boolean equals(Object other)
Compares the String with an Object

Overrides:
equals in class Object
Returns:
true if the String is equal to the object, false otherwise

hashCode

public int hashCode()
Overrides:
hashCode in class Object