Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## java.lang
Class String

    java.lang.Object
      |
      +--java.lang.String

public final class String
extends Object

String is an array of characters.

As with all classes in the waba.lang package, you can't reference the String class using the full specifier of waba.lang.String. The waba.lang package is implicitly imported. Instead, you should simply access the String class like this:

     String s = new String("Hello");

Field Summary
`protected char[]` | `chars`
`protected static Hashtable` | `internalStringPool` The internal string pool (used by intern() method).

Constructor Summary
`String()` Creates an empty string.
`String(byte[] value)` Creates a string from the given byte array.
`String(byte[] value, int offset, int count)` Creates a string from the given byte array.
`String(char[] c)` Creates a string from the given character array.
`String(char[] c, int offset, int count)` Creates a string from a portion of the given character array.
`String(String s)` Creates a copy of the given string.

Method Summary
`char` | `charAt(int i)` Returns the character at the given position.
`static void` | `clearInternalStringPool()` Empties the internal string pool used by the internal string pool.
`int` | `compareTo(String s)` Compares this string with another lexicographically.
`String` | `concat(String s)` Changed by dgecawich (5/14/01)
`boolean` | `endsWith(String suffix)` Tests if this string ends with the specified suffix.
`boolean` | `equals(Object obj)` Returns true if the given string is equal to this string and false otherwise.
`boolean` | `equalsIgnoreCase(String s)` Returns true if the given string is equal to this string and false otherwise.
`byte[]` | `getBytes()` return this String as bytes.The chars are converted to byte using the CharacterConverter associated in the charConverter member of waba.sys.Convert.
`void` | `getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)` Copies characters from this String into the specified character array.
`int` | `hashCode()` returns the hashcode of this object.
`int` | `indexOf(int c)` returns the index of the specified char in this string starting from 0, or -1 if not found
`int` | `indexOf(int c, int startIndex)` returns the index of the specified char in this string, or -1 if not found
`int` | `indexOf(String c)` returns the index of the specified string in this string, or -1 if not found or the index is invalid
`int` | `indexOf(String c, int startIndex)` returns the index of the specified string in this string, or -1 if not found or the index is invalid
`String` | `intern()` Returns a canonical representation for the string object.
`int` | `lastIndexOf(int c)` returns the last index of the specified string in this string starting from length-1, or -1 if not found
`int` | `lastIndexOf(int c, int startIndex)` returns the last index of the specified char in this string, or -1 if not found
`int` | `length()` Returns the length of the string in characters.
`String` | `replace(char oldChar, char newChar)` Returns a new String with the given oldChar replaced by the newChar
`boolean` | `startsWith(String prefix)` Tests if this string starts with the specified prefix.
`boolean` | `startsWith(String prefix, int to)` Tests if this string starts with the specified prefix.
`String` | `substring(int start)` Returns a substring starting from start to the end of the string.
`String` | `substring(int start, int end)` Returns a substring of the string.
`char[]` | `toCharArray()` Returns this string as a character array.
`String` | `toLowerCase()` Returns this string converted to lower case
`String` | `toString()` Returns this string.
`String` | `toUpperCase()` Returns this string converted to upper case
`String` | `trim()` Removes characters less than or equal to ' ' (spaces) from the beginning and end of this String
`static String` | `valueOf(boolean b)` Converts the given boolean to a String.
`static String` | `valueOf(char c)` Converts the given char to a String.
`static String` | `valueOf(double d)` Converts the given double to a String.
`static String` | `valueOf(float f)` Converts the given float to a String.
`static String` | `valueOf(int i)` Converts the given int to a String.
`static String` | `valueOf(long l)` Converts the given double to a String.
`static String` | `valueOf(Object obj)` Returns the string representation of the given object.

Methods inherited from class java.lang.Object
`getClass, notify, wait, wait`

Field Detail

### chars

    protected char[] chars

### internalStringPool

    protected static Hashtable internalStringPool

  The internal string pool (used by intern() method).

Constructor Detail

### String

    public String()

  Creates an empty string.

### String

    public String(String s)

  Creates a copy of the given string.

### String

    public String(char[] c)

  Creates a string from the given character array.

### String

    public String(char[] c,
                  int offset,
                  int count)

  Creates a string from a portion of the given character array.
  Parameters:
    `c` - the character array
    `offset` - the position of the first character in the array
    `count` - the number of characters

### String

    public String(byte[] value,
                  int offset,
                  int count)

  Creates a string from the given byte array. The bytes are converted to char using the CharacterConverter associated in the charConverter member of waba.sys.Convert.

### String

    public String(byte[] value)

  Creates a string from the given byte array. The bytes are converted to char using the CharacterConverter associated in the charConverter member of waba.sys.Convert.

Method Detail

### length

    public int length()

  Returns the length of the string in characters.

### charAt

    public char charAt(int i)

  Returns the character at the given position.

### concat

    public String concat(String s)

  Changed by dgecawich (5/14/01)

### toCharArray

    public char[] toCharArray()

  Returns this string as a character array. The array returned is allocated by this method and is a copy of the string's internal character array.

### toString

    public String toString()

  Returns this string.
  Overrides:
    toString in class Object

### valueOf

    public static String valueOf(Object obj)

  Returns the string representation of the given object.

### substring

    public String substring(int start,
                            int end)

  Returns a substring of the string. The start value is included but the end value is not. That is, if you call:

       string.substring(4, 6);

  a string created from characters 4 and 5 will be returned.
  Parameters:
    `start` - the first character of the substring
    `end` - the character after the last character of the substring

### substring

    public String substring(int start)

  Returns a substring starting from start to the end of the string.
  Parameters:
    `start` - the first character of the substring

### startsWith

    public boolean startsWith(String prefix,
                              int to)

  Tests if this string starts with the specified prefix.
  Parameters:
    `prefix` - the prefix.
    `to` - where to begin looking in the string.
  Returns:
    `true` if the character sequence represented by the argument is a prefix of the substring of this object starting at index `toffset`; `false` otherwise.

### startsWith

    public boolean startsWith(String prefix)

  Tests if this string starts with the specified prefix.
  Parameters:
    `prefix` - the prefix.
  Returns:
    `true` if the character sequence represented by the argument is a prefix of the character sequence represented by this string; `false` otherwise.
  Since:
    JDK1. 0

### endsWith

    public boolean endsWith(String suffix)

  Tests if this string ends with the specified suffix.
  Parameters:
    `suffix` - the suffix.
  Returns:
    `true` if the character sequence represented by the argument is a suffix of the character sequence represented by this object; `false` otherwise.

### equalsIgnoreCase

    public boolean equalsIgnoreCase(String s)

  Returns true if the given string is equal to this string and false otherwise.

### replace

    public String replace(char oldChar,
                          char newChar)

  Returns a new String with the given oldChar replaced by the newChar

### lastIndexOf

    public int lastIndexOf(int c,
                           int startIndex)

  returns the last index of the specified char in this string, or -1 if not found

### lastIndexOf

    public int lastIndexOf(int c)

  returns the last index of the specified string in this string starting from length-1, or -1 if not found

### trim

    public String trim()

  Removes characters less than or equal to ' ' (spaces) from the beginning and end of this String

### getChars

    public void getChars(int srcBegin,
                         int srcEnd,
                         char[] dst,
                         int dstBegin)

  Copies characters from this String into the specified character array. The characters of the specified substring (determined by srcBegin and srcEnd) are copied into the character array, starting at the array's dstBegin location.
  Parameters:
    `srcBegin` - index of the first character in the string
    `srcEnd` - end of the characters that are copied
    `dst` - the destination array
    `dstBegin` - the start offset in the destination array
  Since:
    SuperWaba2.0

### intern

    public String intern()

  Returns a canonical representation for the string object. A pool of strings, initially empty, is maintained privately by the class String. When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned. It follows that for any two strings s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true. All literal strings and string-valued constant expressions are interned.

### clearInternalStringPool

    public static void clearInternalStringPool()

  Empties the internal string pool used by the internal string pool. This is necessary to reduce memory consumption required for the internal string pool on mobile devices.

### getBytes

    public byte[] getBytes()

  return this String as bytes.The chars are converted to byte using the CharacterConverter associated in the charConverter member of waba.sys.Convert.
  Since:
    SuperWaba2.0beta4

### toUpperCase

    public String toUpperCase()

  Returns this string converted to upper case

### toLowerCase

    public String toLowerCase()

  Returns this string converted to lower case

### indexOf

    public int indexOf(String c)

  returns the index of the specified string in this string, or -1 if not found or the index is invalid

### valueOf

    public static String valueOf(long l)

  Converts the given double to a String.

### valueOf

    public static String valueOf(boolean b)

  Converts the given boolean to a String.

### valueOf

    public static String valueOf(double d)

  Converts the given double to a String.

### valueOf

    public static String valueOf(char c)

  Converts the given char to a String.

### valueOf

    public static String valueOf(int i)

  Converts the given int to a String.

### valueOf

    public static String valueOf(float f)

  Converts the given float to a String.

### indexOf

    public int indexOf(int c)

  returns the index of the specified char in this string starting from 0, or -1 if not found

### indexOf

    public int indexOf(int c,
                       int startIndex)

  returns the index of the specified char in this string, or -1 if not found

### equals

    public boolean equals(Object obj)

  Returns true if the given string is equal to this string and false otherwise. If the object passed is not a string, false is returned.
  Overrides:
    equals in class Object

### compareTo

    public int compareTo(String s)

  Compares this string with another lexicographically.
  Returns:
    0 if the strings match, a value < 0 if this string is lexicographically less than the string argument; and > 0 if vice-versa.

### indexOf

    public int indexOf(String c,
                       int startIndex)

  returns the index of the specified string in this string, or -1 if not found or the index is invalid

### hashCode

    public int hashCode()

  Description copied from class: Object
  returns the hashcode of this object.
  Overrides:
    hashCode in class Object
  Returns:
    the hashcode for this string

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD