01 29

Other ways to generate random numbers
java.util.Random class
Random rand=new Random(); //Create a Random object
for(int i=0;i<20;i++){//Generate 20 random integers randomly, and Display
int num=rand.nextInt(10);//Return the next pseudo-random number, the integer System.out.println("第"+(i+1)+"The random number is:"+num);
}
Initialize two Random objects with the same seed value, and then call the same method with each object, and the random numbers obtained are also the same. The
String class is located in the java.lang package and has a wealth of methods to
calculate the length of the string and compare String, connection string, extraction string
String class provides the length() method to determine the length of the
string. Return the number of characters in the string.
equals(): Check whether the characters composing the string content are exactly the same
==: judge the two The address of a string in memory,
that is, to determine whether it is the same string object.
String splicing
Method 1: Use "+"
Method 2: Use the concat() method of the String class
Insert picture description here

Guess you like

Origin blog.csdn.net/jokertiger/article/details/113838947