Skip to content

Commit bbe55a1

Browse files
author
xiachaochao
committed
12
1 parent 23a6b3e commit bbe55a1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.xinan.string01;
2+
3+
public class StringDemo01 {
4+
public static void main(String[] args) {
5+
String fileNames = "abc.java;hello.will.txt;hello.java;hello.class";
6+
/*
7+
* String s1 = new String("abcd");
8+
*
9+
* System.out.println(s == s1); System.out.println(s.trim());
10+
* System.out.println(s.replace('a', 'b'));
11+
* System.out.println(s.indexOf('b')); System.out.println(s.length());
12+
*
13+
* System.out.println(s.charAt(5)); System.out.println(s.isEmpty());
14+
* System.out.println(s.indexOf('a'));
15+
*/
16+
String[] names = fileNames.split(";");
17+
for (String name : names) {
18+
if (name.startsWith("hello")) {
19+
int index = name.lastIndexOf(".");
20+
String newName = name.substring(index);
21+
System.out.println(newName);
22+
}
23+
}
24+
}
25+
26+
}

0 commit comments

Comments
 (0)