String总结-部分
来源:互联网 发布:淘宝秋季新款女装套装 编辑:程序博客网 时间:2024/05/16 01:42
Modifier and Type
Method and Description
char
charAt(int index)
Returns the char value at the specified index.
public class TestCharAt {
public static void charAt(int index) {
}
public static void main(String[] args) {
String a="sophie";
char c=a.charAt(1);
System.out.println(c);
}
} //this method can be read as char at index
int
codePointAt(int index)
Returns the character (Unicode code point) at the specified index.
public class Test2 {
public static void main(String[] args) {
String a="sophiea";
int c=a.codePointAt(6); //charAt is the same result 97
System.out.println(c);
}
}
int
codePointBefore(int index)
Returns the character (Unicode code point) before the specified index
public class Test2 {
public static void main(String[] args) {
String a="sophieaa";
int c=a.codePointBefore(7);
System.out.println(c);
}
} //result is 97
int
codePointCount(int beginIndex, int endIndex)
Returns the number of Unicode code points in the specified text range of this String.
public class Test2 {
public static void main(String[] args) {
String a="sophie";
int c=a.codePointCount(0,0);
System.out.println(c);
}
} //result is 0
int
compareTo(String anotherString)
Compares two strings lexicographically. 字典顺序向量
public class Test2 {
public static void main(String[] args) {
String a="sophie";
int c=a.compareTo("howard");
System.out.println(c);
}
}
int
compareToIgnoreCase(String str)
Compares two strings lexicographically, ignoring case differences.
String
concat(String str)
Concatenates the specified string to the end of this string.
public class Test2 {
public static void main(String[] args) {
String a="sophie";
String b="love";
String c=b.concat(a);
System.out.println(c);
}
} //result is loves
boolean
contains(CharSequence s)
Returns true if and only if this string contains the specified sequence of char values.
public class Test2 {
public static void main(String[] args) {
String a="good study";
boolean b=a.contains(" ");
System.out.println(b);
}
} //result is true
boolean
contentEquals(CharSequence cs)
Compares this string to the specified CharSequence.
public class Test2 {
public static void main(String[] args) {
String a="good study";
boolean b=a.contentEquals("good study");
System.out.println(b);
}
}
static String
copyValueOf(char[] data)
Returns a String that represents the character sequence in the array specified. ?
boolean
endsWith(String suffix)
Tests if this string ends with the specified suffix.
public class Test2 {
public static void main(String[] args) {
String a="good";
boolean b=a.endsWith("od");
System.out.println(b);
}
} //true
int
indexOf(int ch, int fromIndex)
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
int
indexOf(String str)
Returns the index within this string of the first occurrence of the specified substring.
int
indexOf(String str, int fromIndex)
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
public class Test2 {
public static void main(String[] args) {
String a="good day today";
int b=a.indexOf('t',5);
System.out.println(b);
}
}
public class Test2 {
public static void main(String[] args) {
String a="good day today";
int b=a.indexOf("today");
System.out.println(b);
}
}
public class Test2 {
public static void main(String[] args) {
String a="good day today";
int b=a.indexOf("day",9);
System.out.println(b);
}
}
public class Test2 {
public static void main(String[] args) {
String a="good day today";
String b=a.toUpperCase();
String c=b.toLowerCase();
System.out.println(b);
System.out.println(c);
} //GOOD DAY TODAY good day today
}
String
substring(int beginIndex)
Returns a new string that is a substring of this string.
- String总结-部分
- 部分总结
- 部分总结
- string的部分实现
- 部分反转string
- 黑马程序员-Java基础知识3.(部分笔记总结string类)
- String总结
- string 总结
- String总结
- String总结
- string总结
- String总结
- String 总结
- string总结
- OC-自我总结/常用API(部分)
- String类的部分实现
- 第二部分 vector和string
- String类部分函数详解
- flash跨域访问问题
- 为什么?
- bnvn
- Hibernate自定义表单完全解决方案(无需重置SessionFactory)
- 第一次
- String总结-部分
- KILLZONE 2 显示技术详解
- BMI
- UML全解
- 80后的爱情
- 什么时间调用 UpdateData() --MFC函数
- 等待是一种痛苦
- cyberspace :if you don't love it ,leave it
- 还要坚持吗?