Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
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)
<< String Manipulation 1 String Manipulation 3 >>

Post new comment