Java
Java는 오라클에서 개발한 객체 지향적 프로그래밍 언어입니다. Java 소스 코드는 JVM이라는 기계어로 변환되며 플랫폼 독립적인 코드로 작동합니다.
-
[Java] 로또번호 발생기 import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Random; public class LottoGetNumber extends JFrame implements ActionListener{ //객체 레퍼런스 변수 선언 JTextField tf1,tf2,tf3,tf4,tf5,tf6; JButton btn; //생성자 구현 public LottoGetNumber(){ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //1. 객체생성 tf1 = new JTextField(2); tf2 = new JTextField(2); tf3 = new JTex..
[Java] 로또번호 발생기[Java] 로또번호 발생기 import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Random; public class LottoGetNumber extends JFrame implements ActionListener{ //객체 레퍼런스 변수 선언 JTextField tf1,tf2,tf3,tf4,tf5,tf6; JButton btn; //생성자 구현 public LottoGetNumber(){ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //1. 객체생성 tf1 = new JTextField(2); tf2 = new JTextField(2); tf3 = new JTex..
2012.10.25 -
로또번호 발생기 프로젝트 => 시나리오 구성 1. 화면 구성을 어떻게? - 어떤 컴포넌트를 사용 ? => JTextField 6개, JButton 1개 - 컨테이너에 컴포넌트를 어떤 배치 방버으로 배치 ? => FlowLayout 2. 이벤트 연결 및 이벤트 핸들러 처리를 한다 (1) 첫번째 방법론 1. 정수 고정배열 생성 2. 난수 발생 => Random 클래스의 nextInt() 매소드 적용 nextInt(45) + 1 //1~45까지 얻어옴 => 0~44까지 난수 발생함 3. 난수를 배열에 저장 => 숫자 중복체크 4. 숫자 6개를 정수 배열에 저장
[Java] 로또번호 발생기 시나리오로또번호 발생기 프로젝트 => 시나리오 구성 1. 화면 구성을 어떻게? - 어떤 컴포넌트를 사용 ? => JTextField 6개, JButton 1개 - 컨테이너에 컴포넌트를 어떤 배치 방버으로 배치 ? => FlowLayout 2. 이벤트 연결 및 이벤트 핸들러 처리를 한다 (1) 첫번째 방법론 1. 정수 고정배열 생성 2. 난수 발생 => Random 클래스의 nextInt() 매소드 적용 nextInt(45) + 1 //1~45까지 얻어옴 => 0~44까지 난수 발생함 3. 난수를 배열에 저장 => 숫자 중복체크 4. 숫자 6개를 정수 배열에 저장
2012.10.25 -
[Java] 버튼이벤트 import java.awt.*; //Button,Frame,TextArea 클래스 import java.awt.event.*; //ActionListener 인터페이스 public class ButtonEvent extends Frame implements ActionListener{ //1단계 => 객체변수 선언 Button btn; TextArea txt; //3단계 => 생성자 구현 => //초기화(객체생성, 이벤트 연결,컴퍼넌트배치) public ButtonEvent(){ //객체생성 btn = new Button("버튼을 눌러주세요"); txt = new TextArea(); //이벤트연결 btn.addActionListener(this); //컴포넌트배치 setLayo..
[Java] 버튼이벤트[Java] 버튼이벤트 import java.awt.*; //Button,Frame,TextArea 클래스 import java.awt.event.*; //ActionListener 인터페이스 public class ButtonEvent extends Frame implements ActionListener{ //1단계 => 객체변수 선언 Button btn; TextArea txt; //3단계 => 생성자 구현 => //초기화(객체생성, 이벤트 연결,컴퍼넌트배치) public ButtonEvent(){ //객체생성 btn = new Button("버튼을 눌러주세요"); txt = new TextArea(); //이벤트연결 btn.addActionListener(this); //컴포넌트배치 setLayo..
2012.10.25 -
[Java] car public class car { //객체가 가져야할 속성 정의 =>멤버변수 선언 int speed; //현재속도 int wheelNum;//바퀴의 갯수 String carName;//자동차 이름 //생성자 구연 =>규칙 //디폴트 생성자 구현(하위 클래스를위한) //디폴드 생성자는 밑에 생성자 들의 부모격이다. public car(){ //인자,내용도 없는 것는 생성자 가 디폴트 생성자 } public car(String name){ carName = name; } public car(int velocity){ speed = velocity; } public car(String name,int velocity){ carName = name; speed = velocity; } pub..
[Java] car[Java] car public class car { //객체가 가져야할 속성 정의 =>멤버변수 선언 int speed; //현재속도 int wheelNum;//바퀴의 갯수 String carName;//자동차 이름 //생성자 구연 =>규칙 //디폴트 생성자 구현(하위 클래스를위한) //디폴드 생성자는 밑에 생성자 들의 부모격이다. public car(){ //인자,내용도 없는 것는 생성자 가 디폴트 생성자 } public car(String name){ carName = name; } public car(int velocity){ speed = velocity; } public car(String name,int velocity){ carName = name; speed = velocity; } pub..
2012.10.25 -
[Java] Scanner을 이용한 순차검색 import java.util.*; //scanner 클래스를 포함 public class test { public static void main(String arhs[]){ int i,find; int data[] = {30, 10, 50, 40, 20}; System.out.print("찾고자 하는 숫자는 ?"); Scanner in = new Scanner(System.in); find = in.nextInt(); for(i=0; i Scans the next token of the input as an int. [참고] Scanner 클래스는 JDK 1.5이후부터 지원된다.
[Java] Scanner을 이용한 순차검색[Java] Scanner을 이용한 순차검색 import java.util.*; //scanner 클래스를 포함 public class test { public static void main(String arhs[]){ int i,find; int data[] = {30, 10, 50, 40, 20}; System.out.print("찾고자 하는 숫자는 ?"); Scanner in = new Scanner(System.in); find = in.nextInt(); for(i=0; i Scans the next token of the input as an int. [참고] Scanner 클래스는 JDK 1.5이후부터 지원된다.
2012.10.25 -
[Java] 문자열 검색 import java.util.*; public class test { public static void main(String arhs[]){ int i; String str[] = new String[4]; str[0] = "홍길동"; str[1] = "가나다"; str[2] = "다나가"; str[3] = "이얏호"; System.out.print("찾고자 하는 사람은?"); Scanner in = new Scanner(System.in); String find = in.next(); for(i=0; i
[Java] 문자열 검색[Java] 문자열 검색 import java.util.*; public class test { public static void main(String arhs[]){ int i; String str[] = new String[4]; str[0] = "홍길동"; str[1] = "가나다"; str[2] = "다나가"; str[3] = "이얏호"; System.out.print("찾고자 하는 사람은?"); Scanner in = new Scanner(System.in); String find = in.next(); for(i=0; i
2012.10.25