Austrian ~~ a pen questions are programming problem
1. Extract the string in the alphabet, there are repeated regardless. For example: Enter s = asassad, output: ASD
. 1 public class demo_exp { 2 public static void main (String [] args) { . 3 String S = "ajjbaacsa" ; . 4 demo_exp Sctrl = new new demo_exp (); . 5 System.out.println (sctrl.rmRepeated (S)); . 6 } 7 / * 8 * Clear repeating string of letters algorithm . 9 * / 10 string rmRepeated (string S) { . 11 int len = s.length (); 12 is int K = 0 ; 13 is int COUNT = 0 ; 14 String str = ""; 15 char[] c = new char[len]; 16 for(int i=0;i<len;i++){ 17 c[i] = s.charAt(i); 18 } 19 for(int i=0;i<len;i++){ 20 k=i+1; 21 while(k<len-count){ 22 if(c[i]==c[k]){ 23 for(int j=k;j<len-1;j++){ 24 c[j] = c[j+1];// duplicate letters, from the starting position in the array k move forward bit 25 } 26 is COUNT ++; // number of repeated occurrences of the letter 27 K-- ; 28 } 29 k ++ ; 30 } 31 is 32 } 33 is for ( int I = 0 ; I <len-COUNT; I ++ ) { 34 is STR + = String.valueOf (C [I]); 35 } 36 return STR; 37 [ 38 is } 39 }
2. Read all documents and files under a directory folder
1 public class Test { 2 public static void main(String[] args) { 3 String basePath="D:\\A\\admin"; 4 String[] list=new File(basePath).list(); 5 for (String str : list) { 6 System.out.println(str); 7 } 8 }