String类获取功能
来源:互联网 发布:java 日志重定向 编辑:程序博客网 时间:2024/06/05 20:44
/*
* String类获取功能
*/
public class StringTestAcquire{
public static void main(String[] args) {
method_9();
}
/*
* String类的获取方法
* public String substring(int begin)
* 获取字符串中的一部分 返回新的字符串
* 从指定索引开始,后面的全要
*/
public static void method_9(){
String s = "helloworld";
s = s.substring(1);
System.out.println(s);
}
/*
* String类的获取方法
* public String substring(int begin,int end)
* 获取字符串中的一部分 返回新的字符串
* 开始下标和结束下标,包含头,不包含尾
*/
public static void method_8(){
String s = "helloworld";
//获取字符串的一部分,截取 2,6
s = s.substring(2,6);
System.out.println(s);
}
/*
* String类获取方法
* public int length()
* 获取字符串中字符的个数,也就是字符串的长度
*
* length 数组长度,属性
* length() 字符串长度,方法
*/
public static void method_7(){
String s = "wqdfghjkuty5r4234trghfbvfdeqtryhjgnbdfeqrt6rgfsdewrtrf";
//调用String类的方法length()获取长度
int length = s.length();
System.out.println(length);
}
/*
* String类的获取方法
* public int lastIndexOf(char ch,int formIndex)
* 找指定字符在字符串中最后一次出现的索引,从指定下标处开始找,反向查找
*/
public static void method_6(){
String s = "HelloWorld";
//找l 字符,在字符串s中最后一次出现的索引,从5下标开始
int index = s.lastIndexOf('l',3);
System.out.println(index);
}
/*
* String类的获取方法
* public int lastIndexOf(char ch)
* 找指定字符在字符串中最后一次出现的索引,反向查找
*/
public static void method_5(){
String s = "System.println";
//找t 在字符串s中最后一次出现的索引
int index = s.lastIndexOf('t');
System.out.println(index);
}
/*
* String类的获取方法
* public int indexOf(String s,int formIndex)
* 找一个字符串在另一个字符串中第一次出现的索引,从指定的索引开始找
*/
public static void method_4(){
String s = "System.out.println";
//找字符串out,在字符串s中第一次出现的索引,从10下标开始找
int index = s.indexOf("out",8);
System.out.println(index);
}
/*
* String类的获取方法
* public int indexOf(String s)
* 找一个字符串在另一个字符串中第一次出现的索引
*/
public static void method_3(){
String s = "System.out.println";
//找字符串out在字符串s中第一次出现的索引
int index = s.indexOf("out");
System.out.println(index);
}
/*
* String类的获取方法
* public int indexOf(char ch,int formIndex)
* 获取一个字符,在一个字符串中第一次出现的索引,从指定的下标开始查找
*/
public static void method_2(){
String s = "System.out.println()";
//找字符t 在字符串中第一次出现的索引,指定开始索引从5开始
int index = s.indexOf('t',5);
System.out.println(index);
}
/*
* String类的获取方法
* public int indexOf(char ch)
* 获取一个字符,在一个字符串中第一次出现的索引
* 找不到返回负数
* 通用,获取内容:如果找的是基本类型,找不到返回负数
* 如果找的引用类型数据,找不到返回null
*/
public static void method_1(){
String s = "how are you";
//字符串中,找字符e 第一次出现的索引
int index = s.indexOf('e');
System.out.println(index);
}
/*
* String类的获取方法
* public char charAt(int index)
* 获取指定索引出的单个字符
* "abcd"
*/
public static void method(){
String s = "abcdef";
//获取指定索引上的字符,3
char c = s.charAt(3);
System.out.println(c);
}
}
* String类获取功能
*/
public class StringTestAcquire{
public static void main(String[] args) {
method_9();
}
/*
* String类的获取方法
* public String substring(int begin)
* 获取字符串中的一部分 返回新的字符串
* 从指定索引开始,后面的全要
*/
public static void method_9(){
String s = "helloworld";
s = s.substring(1);
System.out.println(s);
}
/*
* String类的获取方法
* public String substring(int begin,int end)
* 获取字符串中的一部分 返回新的字符串
* 开始下标和结束下标,包含头,不包含尾
*/
public static void method_8(){
String s = "helloworld";
//获取字符串的一部分,截取 2,6
s = s.substring(2,6);
System.out.println(s);
}
/*
* String类获取方法
* public int length()
* 获取字符串中字符的个数,也就是字符串的长度
*
* length 数组长度,属性
* length() 字符串长度,方法
*/
public static void method_7(){
String s = "wqdfghjkuty5r4234trghfbvfdeqtryhjgnbdfeqrt6rgfsdewrtrf";
//调用String类的方法length()获取长度
int length = s.length();
System.out.println(length);
}
/*
* String类的获取方法
* public int lastIndexOf(char ch,int formIndex)
* 找指定字符在字符串中最后一次出现的索引,从指定下标处开始找,反向查找
*/
public static void method_6(){
String s = "HelloWorld";
//找l 字符,在字符串s中最后一次出现的索引,从5下标开始
int index = s.lastIndexOf('l',3);
System.out.println(index);
}
/*
* String类的获取方法
* public int lastIndexOf(char ch)
* 找指定字符在字符串中最后一次出现的索引,反向查找
*/
public static void method_5(){
String s = "System.println";
//找t 在字符串s中最后一次出现的索引
int index = s.lastIndexOf('t');
System.out.println(index);
}
/*
* String类的获取方法
* public int indexOf(String s,int formIndex)
* 找一个字符串在另一个字符串中第一次出现的索引,从指定的索引开始找
*/
public static void method_4(){
String s = "System.out.println";
//找字符串out,在字符串s中第一次出现的索引,从10下标开始找
int index = s.indexOf("out",8);
System.out.println(index);
}
/*
* String类的获取方法
* public int indexOf(String s)
* 找一个字符串在另一个字符串中第一次出现的索引
*/
public static void method_3(){
String s = "System.out.println";
//找字符串out在字符串s中第一次出现的索引
int index = s.indexOf("out");
System.out.println(index);
}
/*
* String类的获取方法
* public int indexOf(char ch,int formIndex)
* 获取一个字符,在一个字符串中第一次出现的索引,从指定的下标开始查找
*/
public static void method_2(){
String s = "System.out.println()";
//找字符t 在字符串中第一次出现的索引,指定开始索引从5开始
int index = s.indexOf('t',5);
System.out.println(index);
}
/*
* String类的获取方法
* public int indexOf(char ch)
* 获取一个字符,在一个字符串中第一次出现的索引
* 找不到返回负数
* 通用,获取内容:如果找的是基本类型,找不到返回负数
* 如果找的引用类型数据,找不到返回null
*/
public static void method_1(){
String s = "how are you";
//字符串中,找字符e 第一次出现的索引
int index = s.indexOf('e');
System.out.println(index);
}
/*
* String类的获取方法
* public char charAt(int index)
* 获取指定索引出的单个字符
* "abcd"
*/
public static void method(){
String s = "abcdef";
//获取指定索引上的字符,3
char c = s.charAt(3);
System.out.println(c);
}
}
0 0
- String类获取功能
- String类的获取功能
- String类的获取功能
- String类的获取功能
- String类的获取功能
- String类的获取功能:
- 三、String类的获取功能
- String类的获取功能(方法)
- java学习日记_60:String类的获取功能
- String-常见功能-获取和判断
- JAVA基础再回首(九)——Object类、String类及其获取功能、转换功能、其他功能
- String类的功能
- String类常用功能
- String类转换功能
- string,stringBuilder,字符串的常用方法,键盘录入字符串,string的构造方法,string类的各种判断功能,string类的各种获取功能,string类的转换功能,切割方法
- 15-03-常用对象API(String类-常见功能-获取_1)
- 15-04-常用对象API(String类-常见功能-获取_2)
- 03-常用对象API(String类-常见功能-获取_1) 1 2 3 05-常用对象API(String类-常见功能-转换)1 2 3 4
- 如何实现一个不规则排列的图片布局算法
- 有哪些实用的计算机相关技能,可以在一天内学会?
- 多线程练习,先用LOCK实现后用synchronized同步实现
- 头
- Singleton单例模式
- String类获取功能
- 升级到Oracle DB 12c之前应该考虑的因素:DB 12c中EM Express 12c的功能减少
- leetcode Edit Distance
- SCU 4439 Vertex Cover (2015四川省省赛D题)
- 2015062201 - 成长
- iframe通信问题及自适应高度
- String类转换功能
- 安装并配置Hadoop伪分布模式
- CSU1657: Ways