File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
JavaBase/src/com/xinan/string01 Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments