import java.util.Random;
Public class Arbitrarily
{
Public static void main (String [] args)
{
Int [] tdarr=new int [35];
for (int i=0; I & lt; 35. I++)
{
Tdarr [I]=I + 1;
}
The Random r=new Random ();//build
For (int j=0; J & lt;=7. J++)
{
Int a=r.n extInt (tdarr [34]);
System.out.println(a);
Remove (tdarr [34], a);
}
}
Private static void remove (int I, int a)
{
}
}
Create an array, and then create a random number in an array, and obtain values will he removed in rewriting in the array gain
CodePudding user response:
Import the Java. Util. ArrayList;
import java.util.Random;
Public class Arbitrarily
{
Public static void main (String [] args)
{
ArrayListAL=new ArrayList (a);
Int [] tdarr=new int [3].
for (int i=0; I & lt; 3; I++)
{
Tdarr [I]=I + 1;
AL. The add (tdarr [I]);
}
For (int j=1; J & lt;=2; J++)
{
The Random r=new Random ();//build
Int a=r.n extInt (aL. The size ());
System.out.println(a);
AL. Remove (a);
}
}
}
Not optimization like this
CodePudding user response:
Well I study out
Import the Java. Util. ArrayList;
import java.util.Random;
Public class Arbitrarily
{
Public static void main (String [] args)
{
ArrayListAL=new ArrayList (a);
Int [] tdarr=new int [35];
for (int i=0; I & lt; 35. I++)
{
Tdarr [I]=I + 1;
AL. The add (tdarr [I]);
}
For (int j=1; J & lt;=7. J++)
{
The Random r=new Random ();//build
Int a=r.n extInt (aL. The size ());
System. The out. Print (aL. Get (a) + ", ");
AL. Remove (a);
}
}
}
Bosses see what place can be optimized under
CodePudding user response:
The individual feels you have a problem in the remove function, because want to remove in the array, but you didn't hand in the array function, don't know how to remove you, I see you this array is a local variable, function get less than, so there should be no removal, you can print the array, removed