Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Define a collection class
Define a collection class

public

static

void

main(string[]

args)

< p>{

//

Define an arraylist collection object and add randomly generated int type data between 0-10 to it,

/ /***Add 10 and print out the even numbers one by one

arraylist

list

=

new

arraylist

();

random

random

=

new

random();

for(int

i

=

0;

i

<

10;

i++){

int

num

< p>=

random.nextint(10);

list.add(num);

}

for

(integer

integer

:

list)

{

if(integer% 2==0){

system.out.println(integer);

}

}

}

Purely made by hand, I hope it can help you, thank you for adopting. . .