Original string is not modified after calling toUpperCase() : String class « Utility Classes « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » String class 
8.7.10.Original string is not modified after calling toUpperCase()
public class MainClass {
  public static void main(String[] argv) {
    String s = "test";
    String t = s.toUpperCase();

    System.out.println(s);
    System.out.println(t);
  }
}
test
TEST
8.7.String class
8.7.1.String in Java
8.7.2.The + Operator and StringBuffer
8.7.3.The overloaded + and += operators perform functions similar to the concat() method
8.7.4.Working with Strings
8.7.5.The most common string constructor takes another string as its input
8.7.6.An easier abbreviation string construction could be
8.7.7.With strings, the equals() method checks the two contained collections of characters.
8.7.8.Use == to compare String literal
8.7.9.toUpperCase() converts all the characters of a string to uppercase.
8.7.10.Original string is not modified after calling toUpperCase()
8.7.11.char charAt(int index) Returns the indexed character of a string, where the index of the initial character is 0.
8.7.12.String concat(String addThis) adds two strings together
8.7.13.int compareTo(String otherString) Performs a lexical comparison
8.7.14.boolean endsWith(String suffix) Returns true if the current string ends with suffix; otherwise returns false.
8.7.15.boolean equals(Object ob) Returns true if ob instanceof String and the ob and the executing object have the same value.
8.7.16.boolean equalsIgnoreCase(String s) Returns true if s matches the current string, ignoring rcase.
8.7.17.int indexOf(int ch) Returns the index within the current string of the first occurrence of ch.
8.7.18.int lastIndexOf(int ch) Returns the index within the current string of the last occurrence of ch.
8.7.19.int length() Returns the number of characters in the current string.
8.7.20.String replace(char oldChar, char newChar) replaces every occurrence of oldChar with newChar.
8.7.21.boolean startsWith(String prefix) Returns true if the current string begins with prefix;
8.7.22.String substring(int startIndex) Returns the substring, beginning at startIndex of the current string and extending to the end of the current string.
8.7.23.String toLowerCase() Converts the executing object to lowercase and returns a new string.
8.7.24.String toString() Returns the executing object (not a copy).
8.7.25.String trim() Returns the string that results from removing whitespace characters from the beginning and ending of the current string.
8.7.26.At compile time, if either operand of a + operator is a String object, then the compiler recognizes that it is in a string context.
8.7.27.In a + b + c, If variable a is a string
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.