|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.String
String is an array of characters.
As with all classes in the java.lang package, you can't reference the String class using the full specifier of java.lang.String. The java.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 |
protected char[] chars
protected static Hashtable internalStringPool
Constructor Detail |
public String()
public String(String s)
public String(char[] c)
public String(char[] c, int offset, int count)
c
- the character arrayoffset
- the position of the first character in the arraycount
- the number of characterspublic String(byte[] value, int offset, int count)
public String(byte[] value)
Method Detail |
public int length()
public char charAt(int i)
public String concat(String s)
public char[] toCharArray()
public String toString()
public static String valueOf(Object obj)
public String substring(int start, int end)
string.substring(4, 6);a string created from characters 4 and 5 will be returned.
start
- the first character of the substringend
- the character after the last character of the substringpublic String substring(int start)
start
- the first character of the substringpublic boolean startsWith(String prefix, int to)
prefix
- the prefix.to
- where to begin looking in the string.true
if the character sequence represented by the
argument is a prefix of the substring of this object starting
at index toffset
; false
otherwise.public boolean startsWith(String prefix)
prefix
- the prefix.true
if the character sequence represented by the
argument is a prefix of the character sequence represented by
this string; false
otherwise.public boolean endsWith(String suffix)
suffix
- the suffix.true
if the character sequence represented by the
argument is a suffix of the character sequence represented by
this object; false
otherwise.public boolean equalsIgnoreCase(String s)
public String replace(char oldChar, char newChar)
public int lastIndexOf(int c, int startIndex)
public int lastIndexOf(int c)
public String trim()
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
srcBegin
- index of the first character in the stringsrcEnd
- end of the characters that are copieddst
- the destination arraydstBegin
- the start offset in the destination arraypublic String intern()
public static void clearInternalStringPool()
public byte[] getBytes()
public String toUpperCase()
public String toLowerCase()
public int indexOf(String c)
public static String valueOf(long l)
public static String valueOf(boolean b)
public static String valueOf(double d)
public static String valueOf(char c)
public static String valueOf(int i)
public static String valueOf(float f)
public int indexOf(int c)
public int indexOf(int c, int startIndex)
public boolean equals(Object obj)
public int compareTo(String s)
public int indexOf(String c, int startIndex)
public int hashCode()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |