JAVA 获取字符串的长度,链接字符串,获取字符串索引位置的值,获取值的索引位置


package Code503;

public class CodeStringGet {
public static void main(String[] args) {
//获取字符串的长度
int length = "huanduchenyu".length();
System.out.println("字符串的长度为:"+length);
String str1="欢都";
String str2="辰玉";
//链接字符串
String str3=str1.concat(str2);
System.out.println(str1);
System.out.println(str2);
System.out.println(str3);
//获取字符串,索引为2的值
System.out.println(str3.charAt(2));
//获取“玉”字在字符串的索引位置
int index = str3.indexOf("玉");
System.out.println("玉出现的位置是:"+index);
}
}
运行代码↓

 




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM