내일배움캠프 STEP 2. 속도에 맞춰 나아가기/JAVA 응용하기
Lv1. 랜덤 닉네임 생성기
김호진02
2024. 10. 22. 17:02

import java.util.Random;
public class Main {
public static void main(String[] args) {
String[] fst= {"기절초풍","멋있는","재미있는"};
String[] sec= {"도전적인","노란색의","바보같은"};
String[] thi= {"돌고래","개발자","오랑우탄"};
// 랜덤 객체 생성
Random rm = new Random();
// 랜덤 인덱스 생성
int fst_rm = rm.nextInt(fst.length);
int sec_rm = rm.nextInt(sec.length);
int thi_rm = rm.nextInt(thi.length);
System.out.println(fst[fst_rm]+" + "+sec[sec_rm]
+" + "+thi[thi_rm]);
}
}