码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2019-05-04 00:11:11      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:链接   concat   ring   com   print   str1   位置   int   img   

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);
}
}
运行代码↓
技术图片

 



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

标签:链接   concat   ring   com   print   str1   位置   int   img   

原文地址:https://www.cnblogs.com/Ssinoo/p/10806944.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!