1, first create method can store the names of the students into a array;
2, a method can display the student's name; Includes an array of serial number number
3, using the random function to create a method, to obtain a random value (is the student number); By the value of the corresponding student name the student is random order name,
Reference code is as follows, the subsequent code own work
Package cn. Itcast. Lx0310;
import java.util.Scanner;
import java.util.Random;
Public class Randomname {
Public static void main (String [] args) {}
Public static void Addname (String [] stus) {Scanner sc=new Scanner (System. In); for (int i=0; i
Public static void Displayname (String [] stus) {for (int I=0; i
}
CodePudding user response:
What effect do you want a program, your tips above code has been almost completed function, as long as in the add a random number, the method of array subscripts, designated by the random number students can achieve random operation, namedGet a Random number of new Random (). NextInt (stus. Length), get a Random integer return, will return to the student's name to complete the integer as a subscript,
CodePudding user response: