/ *
それらの文字列がそこに一般的に用いられている方法に関連します:
公共int型の長さ():文字列の長さを得るために、文字列に含まれる文字の数を取得します。
公共の文字列の連結(String str)文字:現在の文字列パラメータや戻り値文字列の連結は、新しい文字列になります。
公共のcharのcharAt(int index)指定さ:単一の文字のインデックス位置を取得します。(。インデックスがゼロである)
公衆のindexOf(文字列STR)をint型:-1戻り値がない場合、この文字列のパラメータ文字列の最初の出現のインデックス位置を見つけます。
* /
public class Demo02StringGet {
public static void main(String[] args) {
int length = "asdasfeutrvauevbueyvb".length();
System.out.println("字符串的长度是:" + length);
// 拼接字符串
String str1 = "Hello";
String str2 = "World";
String str3 = str1.concat(str2);
System.out.println(str1); // Hello,原封不动
System.out.println(str2); // World,原封不动
System.out.println(str3); // HelloWorld,新的字符串
System.out.println("==============");
// 获取指定索引位置的单个字符
char ch = "Hello".charAt(1);
System.out.println("在1号索引位置的字符是:" + ch);
System.out.println("==============");
// 查找参数字符串在本来字符串当中出现的第一次索引位置
// 如果根本没有,返回-1值
String original = "HelloWorldHelloWorld";
int index = original.indexOf("llo");
System.out.println("第一次索引值是:" + index);
System.out.println("HelloWorld".indexOf("abc")); // -1
}
}