String Manipulation
3. ) Replacing characters in String
The replace method of String can be used to replace all occurrences
of the specified character with given character.
String replace(char
oldChar, int newchar)
4. ) Getting substrings
String class provides substring method to extract specified portion
of the given String. This method has been overloaded.
String substring(int
startIndex)
String substring(int startIndex, int endIndex)
Note : A new String object containing the substring
is created and returned. The original String won’t be affected.
If the index value is not valid, a StringIndexOutOfBoundsException
is thrown.
5. ) Conversions
String class provides set of static overloaded valueOf method to
convert primitives and object into strings.
static String
valueOf(Object obj)
static String valueOf(char[] character)
static String valueOf(boolean b)
static String valueOf(char c)
static String valueOf(int i)
static String valueOf(long l)
static String valueOf(float f)
static String valueOf(double d)
|