반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 결합전문기관
- 자료구조
- mglearn
- cudnn
- classification
- 머신러닝
- KNeighborsClassifier
- discrete_scatter
- inorder
- web 사진
- 데이터전문기관
- web 용어
- web
- paragraph
- 대이터
- C언어
- java역사
- 웹 용어
- CES 2O21 참여
- web 개발
- pycharm
- CES 2O21 참가
- tensorflow
- bccard
- Keras
- vscode
- postorder
- 재귀함수
- html
- broscoding
Archives
- Today
- Total
bro's coding
java.Random 본문
반응형
package step4;
import java.util.Random;
public class TestRandom {
public static void main(String[] args) {
// 임의의 수를 발생시키는 클래스를 테스트
Random r =new Random();
System.out.println(r.nextInt(2));
}
}
Lotto
package step4;
import java.util.TreeSet;
public class TestLottoSet {
public static void main(String[] args) {
LottoService service = new LottoService();
TreeSet<Integer> set = service.createLottoNumber();
System.out.println(set);
}
}
package step4;
import java.util.Random;
import java.util.TreeSet;
public class LottoService {
public TreeSet<Integer> createLottoNumber() {
// TODO Auto-generated method stub
TreeSet<Integer> result = new TreeSet<Integer>();
while (result.size() < 6) {
result.add(new Random().nextInt(45) + 1);
}
return result;
}
}
반응형
'[IT] > java' 카테고리의 다른 글
java.SemiProject.SchoolService (0) | 2021.03.08 |
---|---|
java.iterator(열거형) (0) | 2021.03.05 |
java.DTO/DAO/VO/Service (0) | 2021.03.05 |
javajava.Collection.List (0) | 2021.03.05 |
java.Generic (0) | 2021.03.05 |
java.Collection.Set (0) | 2021.03.05 |
java.Collection (0) | 2021.03.05 |
java.Interface.default/static method (0) | 2021.03.05 |
Comments