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 | 29 | 30 |
Tags
- 국제화
- JSP
- 이클립스
- 배열
- 안드로이드
- JavaScript
- 메서드
- paint
- 클래스
- oracle
- Java
- Spring
- 전화걸기
- HTML
- 어노테이션
- 에러페이지
- OGNL
- Graphic
- layout
- 오버로딩
- AWT
- Android
- Menu
- 기본
- 메소드
- Eclips
- mybatis
- 예외처리
- struts2
- 생성자
Archives
- Today
- Total
note
ArrayList로 로또 만들기 Contains()메소드 사용 본문
package com.list;//로또만들기 ArrayList , Contains메소드 이용해서 import java.util.Collections; import java.util.Random; import java.util.ArrayList; public class ArrayListLotto { public ArrayListLotto(){ make(); } public void make(){ ArrayListvc = new ArrayList (); Random ra = new Random(); Integer ir = null; while(vc.size()<6){ //난수 발생 ir = new Integer(ra.nextInt(45)+1); //중복값 체크 if(!vc.contains(ir)) vc.add(ir); } Collections.sort(vc);//오름차순 for(int i : vc) System.out.print(i+"\t"); } public static void main(String[] args) { new ArrayListLotto(); } }
14 15 23 24 27 35
'자바 > 중요 클래스들' 카테고리의 다른 글
HashMap특성 2 (0) | 2011.12.28 |
---|---|
HashMap 특성 (0) | 2011.12.28 |
HashSet 클래스로 로또 만들기 (0) | 2011.12.28 |
Set 인터페이스 (0) | 2011.12.28 |
LinkedList 클래스 사용 (0) | 2011.12.28 |