Home > Back-end >  Could you tell me how to do this way Java?
Could you tell me how to do this way Java?

Time:12-28

The examination to test this, I not turn a great god

CodePudding user response:

 import org. Springframework. Util. StringUtils; 

Import the Java. Util. Arrays;
Import the Java. Util. Random;
Public class MainTest {

Public static void main (String [] args) {
String STR=new String [] [100].
StringBuffer buffer=new StringBuffer (100);
for (int i=0; i STR [I]=randomString (1);
Buffer. Append (STR [I]);
}
System. The out. Println (buffer);
Int count=method1 (buffer. The toString (), "123");
System. The out. Println (" 123 the number of the substring is: "+ count);

}

/* *
* statistical repeat number
* @ param buffer
* @ param a
* @ return
*/
Public static int method1 (String buffer, String a) {
Int len=buffer. The length () - buffer. The replace (a, ""). The length ();
Return len/a. ength ();
}

/* *
* generated random number
* @ param a
* @ return
*/
Public static String randomString (int a) {
Cs=new char char [] [a];
String pool="";
For (short I='0'. i <='9'; I++) {
The pool=pool + (char) I;
}
For (int h=0; H & lt; Cs. Length; H++) {
Int index=(int) (Math. The random () * pool in length ());//create a random number in the range of the pool
Cs=[h] pool. The charAt (index);//returns the specified index in the characters
}
Strings str1=new String (cs);
Return the str1;
}
}

CodePudding user response:

Thank you, bosses
  • Related