String

来源:互联网 发布:无锡灵山大佛淘宝官网 编辑:程序博客网 时间:2024/05/04 09:03
public class StringClass {public static void main(String[] args) {String s = new String("Welcom to Shandong Normal University");System.err.println(s.length());// Returns the length of this string.System.err.println(s.charAt(0));// Returns the char value at the// specified index.System.err.println(s.isEmpty());// Returns true if, and only if,// length() is 0.System.err.println(s.codePointAt(0));// Returns the character(Unicode// code point) at the specified// index.System.err.println(String.valueOf(1));// Returns the string// representation of the int// argument.System.err.println(s.toUpperCase());// Converts all of the characters in// this String to upper case using// the rules of the default locale.System.err.println(s.startsWith("W"));// Tests if this string starts// with the specified prefix.System.err.println(s.split(" "));// Splits this string around matches of// the given regular expression.System.err.println(s.trim());// Returns a copy of the string, with// leading and trailing whitespace// omitted.System.err.println(s.toCharArray());// Converts this string to a new// character array.// character array.System.err.println(s.substring(7, 9));// Returns a new string that is a// substring of this string.System.err.println(s.indexOf("or"));// Returns the index within this// string of the first occurrence of// the specified substring.}}

0 0