스레드의우선순위 우선순위설정메소드 : void setpriority(int newpriority) newpriority 에설정할수있는등급 : 1( 가장낮은우선순위 ) 부터 10( 가장높은우선순위 ) 가장높은우선순위 : MAX_PRIORITY, 보통우선순위 : NORM_

Size: px
Start display at page:

Download "스레드의우선순위 우선순위설정메소드 : void setpriority(int newpriority) newpriority 에설정할수있는등급 : 1( 가장낮은우선순위 ) 부터 10( 가장높은우선순위 ) 가장높은우선순위 : MAX_PRIORITY, 보통우선순위 : NORM_"

Transcription

1 10 초동안사용자가입력하지않으면종료하는예제 ) import javax.swing.joptionpane; class AutoTermination { static boolean inputcheck = false; public static void main(string[] args) throws Exception { FirstThread th1 = new FirstThread(); SecondThread th2 = new SecondThread(); th1.start(); th2.start(); class FirstThread extends Thread {// 입력값을받는일을하는스레드 System.out.println("10초안에값을입력해야합니다."); String input = JOptionPane.showInputDialog(" 아무값이나입력하세요."); AutoTermination.inputCheck = true; System.out.println(" 입력값은 " + input + " 입니다."); class SecondThread extends Thread {//10초카운트를하는스레드 for(int i=9; i >= 0; i--) { if(autotermination.inputcheck) break; System.out.println(i); try { sleep(1000);//1초동안대기 catch(interruptedexception e ) { System.out.println("10초동안값이입력되지않아종료합니다."); System.exit(0);// 모든프로그램종료 // 즉, 값이입력되면종료. 값이입력되지않아도 10초가지나면종료 - 1 -

2 스레드의우선순위 우선순위설정메소드 : void setpriority(int newpriority) newpriority 에설정할수있는등급 : 1( 가장낮은우선순위 ) 부터 10( 가장높은우선순위 ) 가장높은우선순위 : MAX_PRIORITY, 보통우선순위 : NORM_PRIORITY, 가장낮은우선순위 : MIN_PRIORITY public static final int MAX_PRIORITY = 10; public static final int NORM_PRIORITY = 5; public static final int MIN_PRIORITY = 1; 우선순위를읽는메소드 : int getpriority() 우선순위설정예 ) class MyThread extends Thread { public MyThreadString name) { super(name); System.out.println(getName()+ " 스레드 "); class ThreadPriorityTest { public static void main(string[] str) { MyThread obj1 = new MyThread(" 최고우선순위 "); MyThread obj2 = new MyThread(" 보통우선순위 "); MyThread obj3 = new MyThread(" 최저우선순위 "); obj1.setpriority(thread.max_priority); // 최고우선순위 obj2.setpriority(thread.norm_priority); // 보통우선순위 obj3.setpriority(thread.min_priority); // 최저우선순위 obj3.start(); obj2.start(); obj1.start(); - 2 -

3 우선순위설정예 ) class ThreadPriorityTest { public static void main(string args[]) { Thread1 th1 = new Thread1(); Thread2 th2 = new Thread2(); th2.setpriority(7);// 두번째스레드의우선순위를 7 등급으로설정 System.out.println("Priority of th1(-) : " + th1.getpriority() ); System.out.println("Priority of th2( ) : " + th2.getpriority() ); th1.start();// 스레드시작 th2.start();// 스레드시작 class Thread1 extends Thread { for(int i=0; i < 300; i++) { System.out.print("-"); for(int x=0; x < ; x++); class Thread2 extends Thread { for(int i=0; i < 300; i++) { System.out.print(" "); for(int x=0; x < ; x++); - 3 -

4 데몬스레드 (Daemon Thread) 데몬스레드는일반스레드의작업을돕는보조적인역할을수행하는스레드이다. 일반스레드가모두종료되면데몬 스레드는강제적으로종료된다. 더이상보조적인역할을수행할수없기때문이다. 보저적인역할을한다는점만제외하고는다른스레드와동일하다. 데몬스레드는무한반복으로실행하면서대기하고있다가특정조건이만족되면작업을수행하고다시대기하도록작성한다. 데몬스레드는일반스레드의작성방법과실행방법이동일하며다만스레드를생성한후실행하기전에 setdaemon(true) 를호출하기만하면된다. 또한, 데몬스레드에서또다른스레드를생성한다면이스레드도데몬스레드가된다. boolean isdaemon() : 데몬스레드인지를검사하는메소드. 데몬스레드이면 true 를반환한다. void setdaemon(boolean on) : 데몬스레드로설정하는메소드 - 4 -

5 3 초마다변수 autosave 의값을확인해서그값이 true 이면, 자동으로저장하는일을무한히반복하는스레드 ) class AutoSaveTest implements Runnable { static boolean autosave = false; public static void main(string[] args) {// 주스레드 Thread t = new Thread(new AutoSaveTest()); t.setdaemon(true);// 이부분이없으면보조스레드는종료되지않는다. t.start();// 데몬스레드시작 for(int i=1; i <= 20; i++) {//20초동안반복 try{ Thread.sleep(1000);//1초동안대기 catch(interruptedexception e) { System.out.println(i);//i 값을화면에출력, 1 부터 20까지 1초간격으로출력된다. if(i==5)// 처음에 5 초가되면 autosave 를 true 로설정해서 자동저장 되도록함 autosave = true; System.out.println(" 프로그램을종료합니다."); // 데몬스레드 ( 보조스레드 : 주스레드가종료되면강제적으로종료된다.) while(true) { try { Thread.sleep(3 * 1000); //3초동안대기 catch(interruptedexception e) { // autosave의값이 true이면 autosave() 를호출한다. if(autosave) { autosave(); //3초동안대기한후에다시 autusave값이 true인지를검사한다. public void autosave() { System.out.println(" 작업파일이자동저장되었습니다."); - 5 -

6 스레드의상태제어 스레드를실행시키면특별한조치를취하기전까지는스레드들은독립적으로실행되고종료된다. 그런데, 임의로스레 드들간의실행을조절할필요가있다. 이러한경우에몇가지메소드를사용해서스레드의실행상태를조절할수있 다. join() 메소드는이메소드를호출한스레드가일시정시상태가된다. 다음의예는 main 스레드가 th1 과 th2 스레드가모두종료될때까지기다렸다가나중에종료되는프로그램이다. class ThreadStateTest { static long starttime = 0; public static void main(string args[]) { Thread1 th1 = new Thread1(); Thread2 th2 = new Thread2(); th1.start(); th2.start(); starttime = System.currentTimeMillis(); try { th1.join();// th1 스레드의작업이끝날때까지기다린다. th2.join();// th2 스레드의작업이끝날때까지기다린다. catch(interruptedexception e) { System.out.print(" 소요시간 :" + (System.currentTimeMillis() - ThreadStateTest.startTime)); // main class Thread1 extends Thread { for(int i=0; i < 300; i++) { System.out.print("-"); // run() class Thread2 extends Thread { for(int i=0; i < 300; i++) { System.out.print(" "); // run - 6 -

7 첫번째스레드가모두종료된후에두번째스레드를실행시키는예 ) class ThreadStateTest2 { public static void main(string args[]) { Thread1 th1 = new Thread1(); Thread2 th2 = new Thread2(); th1.start();// 첫번째스레드시작 try { th1.join();// 첫번째스레드가완전히종료될때까지기다린다. catch(interruptedexception e) { th2.start();// 두번째스레드시작 class Thread1 extends Thread { for(int i=0; i < 300; i++) { System.out.print("-"); class Thread2 extends Thread { for(int i=0; i < 300; i++) { System.out.print(" "); - 7 -

8 interrupt() 메소드는잠자고있는 (sleep 상태에있는 ) 메소드를깨워서실행대기상태로변경시킨다. 다음은 interrupt() 메소드를이용해서잠자고있는데몬스레드를깨워서일을하도록하는예이다. 이프로그램은가비지컬렉션, 즉사용가능한메모리크기가줄어들면자동으로메모리청소작업을진행해서사용가능 한메모리크기를증가시키는일을한다. 가비지컬렉션은데몬스레드로설정한다. class ThreadInterruptTest { public static void main(string args[]) { GargabeCollection gc = new GargabeCollection();// 가비지컬렉션역할의스레드생성 gc.setdaemon(true);//gargabecollection 스레드를데몬스레드로설정 gc.start();// 가비지컬렉션스레드시작 int requiredmemory = 0;// 필요한메모리의크기. for(int i=0; i < 20; i++) { requiredmemory = (int)(math.random() * 10) * 20; // 필요한메모리의크기를난수를사용해서설정한다. // 즉, 컴퓨터에서동작하는프로그램에서사용하려는메모리의크기를흉내낸것이다. // 필요한메모리가사용할수있는양보다크거나전체메모리의 60% 이상을 // 사용했을경우 gc를깨운다. if(gc.freememory() < requiredmemory gc.freememory() < gc.totalmemory() * 0.4) { gc.interrupt();// 잠자고있는데몬스레드를깨운다. gc.usedmemory += requiredmemory; // 사용중인메모리크기가프로그램에서사용하는메모리크기만큼증가한다. System.out.println("usedMemory:"+gc.usedMemory);// 사용중인메모리크기를출력 - 8 -

9 class GargageCollection extends Thread { final static int MAX_MEMORY = 1000;// 메모리의최대크기, 즉메모리크기가 1000 이상이될수없슴 int usedmemory = 0;// 사용중인메모리크기 while(true) { try { Thread.sleep(10 * 1000);//10초를자고일어나서가비지컬렉션을수행한다. catch(interruptedexception e) { System.out.println("Awaken by interrupt()."); //gc.interrupt(); 에의해서스레드가잠에서깰때이예외가발생한다. gc();//10초동안자고일어나서 garbage collection을수행한다. System.out.println("Garbage Collected. Free Memory :" + freememory()); // 가비지컬렉션을수행한후의메모리크기를출력한다. public void gc() {// 가비지컬렉션을수행하는메소드 usedmemory -= 300;// 사용중인메모리크기를줄인다. if(usedmemory < 0) usedmemory = 0;// 사용중인메모리값이마이너스가되지않도록한다. public int totalmemory() {// 전체메모리크기를알려주는메소드 return MAX_MEMORY; public int freememory() {// 사용가능한메모리크기를알려주는메소드 return MAX_MEMORY - usedmemory; 위의스레드프로그램은메모리의최대크기가 1000으로설정되었기때문에, 어떠한경우에도출력된메모리의크기가 1000을넘을수없다. 그러나, 반복해서실행하다보면사용중인메모리의크기가 1000을넘어가는현상을발견할수있다. 무슨이유때문인지생각해본다

10 우선, 프로그램의실행과정을살펴본다. 메인스레드 1. 사용중인메모리의크기를점점증가시킨다. 2. 사용중인메모리의크기가일정수준을넘어서면, 데몬스레드를깨운다. ( 데몬스레드가자고있으면, 깨어나고, 깨어있으면아무일도일어나지않는다.) 3. 다시 1의작업을진행한다. 데몬스레드 1. 10초동안잠잔다. ( 메인스레드가 interrupt() 메소드를사용 해서깨우면 2 의작업을수행한다.) 2. 깬다. 3. 깨어나서가비지컬렉션을수행한다. 4. 다시 1 의작업을진행한다. 위의표와같이메인스레드와데몬스레드가독자적으로작업을진행한다. 이유는다음과같다. 메인스레드가 2단계에서데몬스레드를깨운후, 데몬스레드가 3단계작업을할때까지기다리지않고, 곧장 1단계작업을수행하기때문이다. 왜냐하면, 스레드들은서로독자적으로실행되기때문이다. 따라서, 메모리의크기를줄이는작업을시작하기바로직전에메모리크기를계속해서증가시키는작업을하기때문이다. 그러면, 어떻게해야이문제를해결할수있을까? 메인스레드가데몬스레드에게시간을강제적으로줘서가비지컬렉션작업을할시작전인여유를보장하는것이다. 즉, 다음과같이잠자고있는데몬스레드를깨우는일만하는것이아니라, gc.interrupt();// 잠자고있는데몬스레드를깨운다. 깨우고나서일정한시간을기다려서가비지컬렉션작업을할수있도록작업시간을보장해준다. gc.interrupt();// 잠자고있는데몬스레드를깨운다. try { gc.join(100);// 가비지컬렉션이 0.1초동안일을할동안기다린다. catch (InterruptedException e) { 문제해결!!!

11 스레드의동기화 다음예에서스레드클래스의지역변수와인스턴스변수값의변화를살펴본다. class ThreadVariableTest { public static void main(string args[]) { RunnableImpl r = new RunnableImpl(); Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); class RunnableImpl implements Runnable { int iv = 0;// 인스턴스변수 int lv =0;// 지역변수 String name = Thread.currentThread().getName();// 스레드의이름 while(lv < 3) { System.out.println(name + " 지역변수 : " + ++lv);// 지역변수값을 1증가 System.out.println(name + " 인스턴스변수 : " + ++iv);// 인스턴스변수값을 1증가 System.out.println(); // run() 이프로그램의결과를꼭확인한다!!! 하나의인스턴스 (RunnableImpl) 를두개의스레드가공유하기때문에인스턴스변수 iv 값은두스레드에서모두 접근이가능하다. 따라서, 계속해서증가를한다. 지역변수는공유되지않기때문에즉, 콜스텍에생성되므로공유되 지않는다, 지역변수값은스레드에영향을받지않는다. RunnableImpl r = new RunnableImpl();// 딱한번인스턴스를생성했으므로, 인스턴스변수도딱하나만생성된다. Thread t1 = new Thread(r);//r 을공유하고있다. Thread t2 = new Thread(r);//r 을공유하고있다

12 그런데, 다음의경우는인스턴스가두개이므로인스턴스변수도두개가생성된다. class ThreadVariableTest { public static void main(string args[]) { RunnableImpl r1 = new RunnableImpl();// 첫번째인스턴스생성 RunnableImpl r2 = new RunnableImpl();// 두번째인스턴스생성 Thread t1 = new Thread(r1); Thread t2 = new Thread(r2); t1.start(); t2.start(); 이전프로그램과위프로그램의결과를비교해본다!!!

13 스레드를이용한은행의 ATM 을이용한입출금예 ) 이프로그램은서로다른두명의사용자가하나의계좌에출금을시도하는내용이다. public class Bank_of_Thread { public static void main(string[] args) { Runnable r = new RunnableEx24(); Thread t1 = new Thread(r);// 첫번째스레드, 즉첫번째사용자에해당한다. Thread t2 = new Thread(r);// 두번째스레드, 즉두번째사용자에해당한다. t1.start();// 출금시도 t2.start();// 출금시도 class Account { int balance = 1000;// 현계좌에잔고가 1000 원부터시작 public void withdraw(int money){ if(balance >= money) {// 잔고가출금하려는금액보다크면출금 try { Thread.sleep(1000); catch(exception e) { balance -= money; // withdraw의끝 class RunnableEx24 implements Runnable { Account acc = new Account(); while(acc.balance > 0) { // 100, 200, 300중의한값을임으로선택해서출금 (withdraw) int money = (int)(math.random() * 3 + 1) * 100; acc.withdraw(money);// 지정된금액을출금 System.out.println("balance:"+acc.balance);// 출금후잔고출력 // run() 의끝 위의프로그램을여러번실행시켜서잔고를확인한다. 잔고에마이너스상태가발생하는가? 발생하면왜발생하는지생각해본다

스레드를적용하지않은결과와스레드를적용한결과의비교 1) 두개의작업을스레드를사용하지않고수행한예 ) : 순차작업 class ThreadTest2 { System.out.print("-");// 화면에 - 를출력하는작업 System.out.print(" ");// 화면에 를출력

스레드를적용하지않은결과와스레드를적용한결과의비교 1) 두개의작업을스레드를사용하지않고수행한예 ) : 순차작업 class ThreadTest2 { System.out.print(-);// 화면에 - 를출력하는작업 System.out.print( );// 화면에 를출력 실 (thread) 을이용한병렬처리 스레드 (thread) 는실을의미한다. 즉, 실하나에여러작업들이꿰어져서순서적으로처리된다. 그런데, 실을여러개 만들고이실에여러작업들을꿰어서이실들을순서적으로처리하게하면, 여러개의작업들이한꺼번에처리된다. 즉, 일정한단위시간당처리되는작업의수를증가시킬수있다. 스레드생성방법에대한예제 ) class ThreadTest1 { ThreadClass1

More information

제11장 프로세스와 쓰레드

제11장 프로세스와 쓰레드 제9장자바쓰레드 9.1 Thread 기초 (1/5) 프로그램 명령어들의연속 (a sequence of instruction) 프로세스 / Thread 실행중인프로그램 (program in execution) 프로세스생성과실행을위한함수들 자바 Thread 2 9.1 Thread 기초 (2/5) 프로세스단위작업의문제점 프로세스생성시오버헤드 컨텍스트스위치오버헤드

More information

PowerPoint Presentation

PowerPoint Presentation public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum +

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 Power Java 제 23 장스레드 이번장에서학습할내용 스레드의개요 스레드의생성과실행 스레드상태 스레드의스케줄링 스레드간의조정 스레드는동시에여러개의프로그램을실행하는효과를냅니다. 멀티태스킹 멀티태스킹 (muli-tasking) 는여러개의애플리케이션을동시에실행하여서컴퓨터시스템의성능을높이기위한기법 스레드란? 다중스레딩 (multi-threading) 은하나의프로그램이동시에여러가지작업을할수있도록하는것

More information

Microsoft PowerPoint - lec12 [호환 모드]

Microsoft PowerPoint - lec12 [호환 모드] 스레드란? 스레드의상태 스레드스케줄링 동기화 스레드그룹 kkman@sangji.ac.kr 2 시작, 실행, 종료의순서를가지는제어흐름단위 단일스레딩시스템 : 오직하나의실행점 멀티스레딩시스템 : 다중의실행점 kkman@sangji.ac.kr 3 Concurrent Programming Multiprogramming System Multiprocessing System

More information

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 (   ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각 JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( http://java.sun.com/javase/6/docs/api ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각선의길이를계산하는메소드들을작성하라. 직사각형의가로와세로의길이는주어진다. 대각선의길이는 Math클래스의적절한메소드를이용하여구하라.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 실습 1 배효철 th1g@nate.com 1 목차 조건문 반복문 System.out 구구단 모양만들기 Up & Down 2 조건문 조건문의종류 If, switch If 문 조건식결과따라중괄호 { 블록을실행할지여부결정할때사용 조건식 true 또는 false값을산출할수있는연산식 boolean 변수 조건식이 true이면블록실행하고 false 이면블록실행하지않음 3

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 3 if, if else, if else if, switch case for, while, do while break, continue : System.in, args, JOptionPane for (,, ) @ vs. logic data method variable Data Data Flow (Type), ( ) @ Member field

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 인터페이스, 람다식, 패키지 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 홈네트워킹 public interface RemoteControl { public void turnon(); // 가전제품을켠다. public void turnoff(); // 가전제품을끈다. 인터페이스를구현 public class Television

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스, 객체, 메소드 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 필드만있는클래스 텔레비젼 2 예제 1. 필드만있는클래스 3 예제 2. 여러개의객체생성하기 4 5 예제 3. 메소드가추가된클래스 public class Television { int channel; // 채널번호 int volume; // 볼륨 boolean

More information

Microsoft PowerPoint - Java7.pptx

Microsoft PowerPoint - Java7.pptx HPC & OT Lab. 1 HPC & OT Lab. 2 실습 7 주차 Jin-Ho, Jang M.S. Hanyang Univ. HPC&OT Lab. jinhoyo@nate.com HPC & OT Lab. 3 Component Structure 객체 (object) 생성개념을이해한다. 외부클래스에대한접근방법을이해한다. 접근제어자 (public & private)

More information

JAVA PROGRAMMING 실습 05. 객체의 활용

JAVA PROGRAMMING 실습 05. 객체의 활용 public class Person{ public String name; public int age; } public Person(){ } public Person(String s, int a){ name = s; age = a; } public String getname(){ return name; } @ 객체의선언 public static void main(string

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 2... ( ). ( ). @ vs. logic data method variable behavior attribute method field Flow (Type), ( ) member @ () : C program Method A ( ) Method B ( ) Method C () program : Java, C++, C# data @ Program

More information

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 8 장클래스와객체 I 이번장에서학습할내용 클래스와객체 객체의일생직접 메소드클래스를 필드작성해 UML 봅시다. QUIZ 1. 객체는 속성과 동작을가지고있다. 2. 자동차가객체라면클래스는 설계도이다. 먼저앞장에서학습한클래스와객체의개념을복습해봅시다. 클래스의구성 클래스 (class) 는객체의설계도라할수있다. 클래스는필드와메소드로이루어진다.

More information

슬라이드 1

슬라이드 1 UNIT 16 예외처리 로봇 SW 교육원 3 기 최상훈 학습목표 2 예외처리구문 try-catch-finally 문을사용핛수있다. 프로그램오류 3 프로그램오류의종류 컴파일에러 (compile-time error) : 컴파일실행시발생 럮타임에러 (runtime error) : 프로그램실행시발생 에러 (error) 프로그램코드에의해서해결될수없는심각핚오류 ex)

More information

Cluster management software

Cluster management software 자바네트워크프로그래밍 (OCJP 국제공인자격취득중심 ) 충북대학교 최민 기본예제 예외클래스를정의하고사용하는예제 class NewException extends Exception { public class ExceptionTest { static void methoda() throws NewException { System.out.println("NewException

More information

Microsoft PowerPoint - java2-lecture6.ppt [호환 모드]

Microsoft PowerPoint - java2-lecture6.ppt [호환 모드] Multi-tasking vs Thread Thread & Multitasking 멀티태스킹 (Multi-tasking) 하나의응용프로그램이여러개의작업 ( 태스크 ) 을동시에처리 스레드 (Thread) 마치바늘이하나의실 (thread) 을가지고바느질하는것과자바의스레드는일맥상통함 514770 2018 년가을학기 11/19/2018 박경신 다림질하면서이어폰으로전화하는주부운전하면서화장하는운전자제품의판독과포장작업의두기능을갖춘기계

More information

(Microsoft PowerPoint - java2-lecture6.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - java2-lecture6.ppt [\310\243\310\257 \270\360\265\345]) 멀티태스킹과스레드개념 Thread & Multitasking 멀티태스킹 (Multi-tasking) 하나의응용프로그램이여러개의작업 ( 태스크 ) 을동시에처리 스레드 (Thread) 마치바늘이하나의실 (thread) 을가지고바느질하는것과자바의스레드는일맥상통함 514770-1 2017 년봄학기 5/10/2017 박경신 다림질하면서이어폰으로전화하는주부운전하면서화장하는운전자제품의판독과포장작업의두기능을갖춘기계

More information

비긴쿡-자바 00앞부속

비긴쿡-자바 00앞부속 IT COOKBOOK 14 Java P r e f a c e Stay HungryStay Foolish 3D 15 C 3 16 Stay HungryStay Foolish CEO 2005 L e c t u r e S c h e d u l e 1 14 PPT API C A b o u t T h i s B o o k IT CookBook for Beginner Chapter

More information

02 C h a p t e r Java

02 C h a p t e r Java 02 C h a p t e r Java Bioinformatics in J a va,, 2 1,,,, C++, Python, (Java),,, (http://wwwbiojavaorg),, 13, 3D GUI,,, (Java programming language) (Sun Microsystems) 1995 1990 (green project) TV 22 CHAPTER

More information

(Microsoft PowerPoint - java1-lecture11.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - java1-lecture11.ppt [\310\243\310\257 \270\360\265\345]) 예외와예외클래스 예외처리 514760-1 2016 년가을학기 12/08/2016 박경신 오류의종류 에러 (Error) 하드웨어의잘못된동작또는고장으로인한오류 에러가발생되면 JVM실행에문제가있으므로프로그램종료 정상실행상태로돌아갈수없음 예외 (Exception) 사용자의잘못된조작또는개발자의잘못된코딩으로인한오류 예외가발생되면프로그램종료 예외처리 추가하면정상실행상태로돌아갈수있음

More information

PowerPoint Presentation

PowerPoint Presentation Class - Property Jo, Heeseung 목차 section 1 클래스의일반구조 section 2 클래스선언 section 3 객체의생성 section 4 멤버변수 4-1 객체변수 4-2 클래스변수 4-3 종단 (final) 변수 4-4 멤버변수접근방법 section 5 멤버변수접근한정자 5-1 public 5-2 private 5-3 한정자없음

More information

JAVA PROGRAMMING 실습 09. 예외처리

JAVA PROGRAMMING 실습 09. 예외처리 2015 학년도 2 학기 예외? 프로그램실행중에발생하는예기치않은사건 예외가발생하는경우 정수를 0으로나누는경우 배열의크기보다큰인덱스로배열의원소를접근하는경우 파일의마지막부분에서데이터를읽으려고하는경우 예외처리 프로그램에문제를발생시키지않고프로그램을실행할수있게적절한조치를취하는것 자바는예외처리기를이용하여예외처리를할수있는기법제공 자바는예외를객체로취급!! 나뉨수를입력하시오

More information

Design Issues

Design Issues 11 COMPUTER PROGRAMMING INHERIATANCE CONTENTS OVERVIEW OF INHERITANCE INHERITANCE OF MEMBER VARIABLE RESERVED WORD SUPER METHOD INHERITANCE and OVERRIDING INHERITANCE and CONSTRUCTOR 2 Overview of Inheritance

More information

Java

Java Java http://cafedaumnet/pway Chapter 1 1 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength();

More information

JAVA PROGRAMMING 실습 08.다형성

JAVA PROGRAMMING 실습 08.다형성 2015 학년도 2 학기 1. 추상메소드 선언은되어있으나코드구현되어있지않은메소드 abstract 키워드사용 메소드타입, 이름, 매개변수리스트만선언 public abstract String getname(); public abstract void setname(string s); 2. 추상클래스 abstract 키워드로선언한클래스 종류 추상메소드를포함하는클래스

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 예외처리 배효철 th1g@nate.com 1 목차 예외와예외클래스 실행예외 예외처리코드 예외종류에따른처리코드 자동리소스닫기 예외처리떠넘기기 사용자정의예외와예외발생 예외와예외클래스 구문오류 예외와예외클래스 구문오류가없는데실행시오류가발생하는경우 예외와예외클래스 import java.util.scanner; public class ExceptionExample1

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 3 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

* Factory class for query and DML clause creation * tiwe * */ public class JPAQueryFactory implements JPQLQueryFactory private f

* Factory class for query and DML clause creation * tiwe * */ public class JPAQueryFactory implements JPQLQueryFactory private f JPA 에서 QueryDSL 사용하기위해 JPAQuery 인스턴스생성방법 http://ojc.asia, http://ojcedu.com 1. JPAQuery 를직접생성하기 JPAQuery 인스턴스생성하기 QueryDSL의 JPAQuery API를사용하려면 JPAQuery 인스턴스를생성하면된다. // entitymanager는 JPA의 EntityManage

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 Power Java 제 11 장상속 이번장에서학습할내용 상속이란? 상속의사용 메소드재정의 접근지정자 상속과생성자 Object 클래스 종단클래스 상속을코드를재사용하기위한중요한기법입니다. 상속이란? 상속의개념은현실세계에도존재한다. 상속의장점 상속의장점 상속을통하여기존클래스의필드와메소드를재사용 기존클래스의일부변경도가능 상속을이용하게되면복잡한 GUI 프로그램을순식간에작성

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 1 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public Chapter 9 Lab 문제정답 1. public class Circle private double radius; static final double PI=3.141592; // PI 이름으로 3.141592 로초기화된정적상수 (1) public Circle(double r) radius = r; (2) public double getradius() return

More information

Microsoft PowerPoint - 04-UDP Programming.ppt

Microsoft PowerPoint - 04-UDP Programming.ppt Chapter 4. UDP Dongwon Jeong djeong@kunsan.ac.kr http://ist.kunsan.ac.kr/ Dept. of Informatics & Statistics 목차 UDP 1 1 UDP 개념 자바 UDP 프로그램작성 클라이언트와서버모두 DatagramSocket 클래스로생성 상호간통신은 DatagramPacket 클래스를이용하여

More information

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

Microsoft PowerPoint 자바-기본문법(Ch2).pptx 자바기본문법 1. 기본사항 2. 자료형 3. 변수와상수 4. 연산자 1 주석 (Comments) 이해를돕기위한설명문 종류 // /* */ /** */ 활용예 javadoc HelloApplication.java 2 주석 (Comments) /* File name: HelloApplication.java Created by: Jung Created on: March

More information

Microsoft PowerPoint - Lect04.pptx

Microsoft PowerPoint - Lect04.pptx OBJECT ORIENTED PROGRAMMING Object Oriented Programming 이강의록은 Power Java 저자의강의록을사용했거나재편집된것입니다. Class 와 object Class 와객체 클래스의일생 메소드 필드 String Object Class 와객체 3 클래스 클래스의구성 클래스 (l (class): 객체를만드는설계도 클래스로부터만들어지는각각의객체를특별히그클래스의인스턴스

More information

파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter

파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter 파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter 클래스의사용법은다음과같다. PrintWriter writer = new PrintWriter("output.txt");

More information

Chap12

Chap12 12 12Java RMI 121 RMI 2 121 RMI 3 - RMI, CORBA 121 RMI RMI RMI (remote object) 4 - ( ) UnicastRemoteObject, 121 RMI 5 class A - class B - ( ) class A a() class Bb() 121 RMI 6 RMI / 121 RMI RMI 1 2 ( 7)

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 오류처리 손시운 ssw5176@kangwon.ac.kr 오류메시지를분석한다. 오류메시지에서많은내용을알수있다. 2 디버깅 디버거를사용하면프로그램에서쉽게오류를감지하고진단할수있다. 디버거는중단점을설정하여서프로그램의실행을제어할수있으며문장 단위로실행하거나변수의값을살펴볼수있다. 3 이클립스에서디버깅 4 이클립스에서디버깅 5 이클립스의디버깅명령어 6 예외처리

More information

rmi_박준용_final.PDF

rmi_박준용_final.PDF (RMI) - JSTORM http://wwwjstormpekr (RMI)- Document title: Document file name: Revision number: Issued by: Document Information (RMI)- rmi finaldoc Issue Date: Status:

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 4 (Object) (Class) (Instance) (Method) (Constructor) Memory 1 UML 1 @ & 1 (Real World) (Software World) @ &.. () () @ & 2 (Real World) (Software World) OOA/ Modeling Abstraction Instantiation

More information

12-file.key

12-file.key 11 (String).. java.lang.stringbuffer. s String s = "abcd"; s = s + "e"; a b c d e a b c d e ,., "910359,, " "910359" " " " " (token) (token),, (delimiter). java.util.stringtokenizer String s = "910359,,

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 오류처리 손시운 ssw5176@kangwon.ac.kr 오류메시지를분석한다. 오류메시지에서많은내용을알수있다. 2 디버깅 디버거를사용하면프로그램에서쉽게오류를감지하고진단할수있다. 디버거는중단점을설정하여서프로그램의실행을제어할수있으며문장 단위로실행하거나변수의값을살펴볼수있다. 3 이클립스에서디버깅 4 이클립스에서디버깅 5 이클립스의디버깅명령어 6 예외처리

More information

자바로

자바로 ! from Yongwoo s Park ZIP,,,,,,,??!?, 1, 1 1, 1 (Snow Ball), /,, 5,,,, 3, 3, 5, 7,,,,,,! ,, ZIP, ZIP, images/logojpg : images/imageszip :, backgroundjpg, shadowgif, fallgif, ballgif, sf1gif, sf2gif, sf3gif,

More information

JMF3_심빈구.PDF

JMF3_심빈구.PDF JMF JSTORM http://wwwjstormpekr Issued by: < > Revision: Document Information Document title: Document file name: Revision number: Issued by: JMF3_ doc Issue Date:

More information

자바-11장N'1-502

자바-11장N'1-502 C h a p t e r 11 java.net.,,., (TCP/IP) (UDP/IP).,. 1 ISO OSI 7 1977 (ISO, International Standards Organization) (OSI, Open Systems Interconnection). 6 1983 X.200. OSI 7 [ 11-1] 7. 1 (Physical Layer),

More information

<4D F736F F F696E74202D20C1A63234C0E520C0D4C3E2B7C228B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63234C0E520C0D4C3E2B7C228B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 24 장입출력 이번장에서학습할내용 스트림이란? 스트림의분류 바이트스트림 문자스트림 형식입출력 명령어행에서입출력 파일입출력 스트림을이용한입출력에대하여살펴봅시다. 스트림 (stream) 스트림 (stream) 은 순서가있는데이터의연속적인흐름 이다. 스트림은입출력을물의흐름처럼간주하는것이다. 스트림들은연결될수있다. 중간점검문제 1. 자바에서는입출력을무엇이라고추상화하는가?

More information

Network Programming

Network Programming Part 5 확장된 Network Programming 기술 1. Remote Procedure Call 2. Remote Method Invocation 3. Object Request Broker 2. Java RMI

More information

PowerPoint Presentation

PowerPoint Presentation public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum +

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 멀티태스킹과스레드의개념이해 2. Thread 클래스를상속받아자바스레드만들기 3. Runnable 인터페이스를구현하여자바스레드만들기 4. 스레드종료시키기 5. 스레드의동기화개념과필요성이해 6. synchronized로간단한스레드동기화 7. wait()-notify() 로간단한스레드동기화 멀티태스킹 (multi-tasking)

More information

PowerPoint Presentation

PowerPoint Presentation 자바프로그래밍 1 클래스와메소드심층연구 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 접근제어 class A { private int a; int b; public int c; // 전용 // 디폴트 // 공용 public class Test { public static void main(string args[]) { A obj = new

More information

Java ...

Java ... 컴퓨터언어 1 Java 제어문 조성일 조건문 : if, switch 어떠한조건을조사하여각기다른명령을실행 if 문, switch 문 if 문 if - else 문형식 if 문형식 if ( 조건식 ) { 명령문 1; 명령문 2;... if ( 조건식 ) { 명령문 1; 명령문 2;... else { 명령문 a; 명령문 b;... 예제 1 정수를입력받아짝수와홀수를판별하는프로그램을작성하시오.

More information

ch09

ch09 9 Chapter CHAPTER GOALS B I G J A V A 436 CHAPTER CONTENTS 9.1 436 Syntax 9.1 441 Syntax 9.2 442 Common Error 9.1 442 9.2 443 Syntax 9.3 445 Advanced Topic 9.1 445 9.3 446 9.4 448 Syntax 9.4 454 Advanced

More information

C++ Programming

C++ Programming C++ Programming 예외처리 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 예외처리 2 예외처리 예외처리 C++ 의예외처리 예외클래스와객체 3 예외처리 예외를처리하지않는프로그램 int main() int a, b; cout > a >> b; cout

More information

05-class.key

05-class.key 5 : 2 (method) (public) (private) (interface) 5.1 (Method), (public method) (private method) (constructor), 3 4 5.2 (client). (receiver)., System.out.println("Hello"); (client object) (receiver object)

More information

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2 객체지향프로그래밍 IT CookBook, 자바로배우는쉬운자료구조 q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2 q 객체지향프로그래밍의이해 v 프로그래밍기법의발달 A 군의사업발전 1 단계 구조적프로그래밍방식 3 q 객체지향프로그래밍의이해 A 군의사업발전 2 단계 객체지향프로그래밍방식 4 q 객체지향프로그래밍의이해 v 객체란무엇인가

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 Power Java 제 9 장생성자와접근제어 이번장에서학습할내용 생성자 정적변수 정적메소드 접근제어 this 클래스간의관계 객체가생성될때초기화를담당하는생성자에대하여살펴봅니다. 생성자 생성자 (contructor): 객체가생성될때에필드에게초기값을제공하고필요한초기화절차를실행하는메소드 생성자의예 class Car { private String color; // 색상

More information

Microsoft PowerPoint - RMI.ppt

Microsoft PowerPoint - RMI.ppt ( 분산통신실습 ) RMI RMI 익히기 1. 분산환경에서동작하는 message-passing을이용한 boundedbuffer 해법프로그램을실행해보세요. 소스코드 : ftp://211.119.245.153 -> os -> OSJavaSources -> ch15 -> rmi http://marvel el.incheon.ac.kr의 Information Unix

More information

JAVA PROGRAMMING 실습 05. 객체의 활용

JAVA PROGRAMMING 실습 05. 객체의 활용 2015 학년도 2 학기 public class Person{ public String name; public int age; public Person(){ public Person(String s, int a){ name = s; age = a; public String getname(){ return name; @ 객체의선언 public static void

More information

gnu-lee-oop-kor-lec06-3-chap7

gnu-lee-oop-kor-lec06-3-chap7 어서와 Java 는처음이지! 제 7 장상속 Super 키워드 상속과생성자 상속과다형성 서브클래스의객체가생성될때, 서브클래스의생성자만호출될까? 아니면수퍼클래스의생성자도호출되는가? class Base{ public Base(String msg) { System.out.println("Base() 생성자 "); ; class Derived extends Base

More information

슬라이드 1

슬라이드 1 UNIT 08 조건문과반복문 로봇 SW 교육원 2 기 학습목표 2 조건문을사용핛수있다. 반복문을사용핛수있다. 조건문 3 조건식의연산결과에따라프로그램의실행흐름을변경 조건문의구성 조건식 실행될문장 조건문의종류 if switch? : ( 삼항연산자 ) if 조건문 4 if 문의구성 조건식 true 또는 false(boolean 형 ) 의결과값을갖는수식 실행될문장

More information

gnu-lee-oop-kor-lec11-1-chap15

gnu-lee-oop-kor-lec11-1-chap15 어서와 Java 는처음이지! 제 15 장컬렉션 컬렉션 (collection) 은자바에서자료구조를구현한클래스 자료구조로는리스트 (list), 스택 (stack), 큐 (queue), 집합 (set), 해쉬테이블 (hash table) 등이있다. 자바는컬렉션인터페이스와컬렉션클래스로나누어서제공한다. 자바에서는컬렉션인터페이스를구현한클래스도함께제공하므로이것을간단하게사용할수도있고아니면각자필요에맞추어인터페이스를자신의클래스로구현할수도있다.

More information

교육자료

교육자료 THE SYS4U DODUMENT Java Reflection & Introspection 2012.08.21 김진아사원 2012 SYS4U I&C All rights reserved. 목차 I. 개념 1. Reflection 이란? 2. Introspection 이란? 3. Reflection 과 Introspection 의차이점 II. 실제사용예 1. Instance의생성

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 배효철 th1g@nate.com 1 목차 표준입출력 파일입출력 2 표준입출력 표준입력은키보드로입력하는것, 주로 Scanner 클래스를사용. 표준출력은화면에출력하는메소드를사용하는데대표적으로 System.out.printf( ) 를사용 3 표준입출력 표준출력 : System.out.printlf() 4 표준입출력 Example 01 public static void

More information

Microsoft Word - EEL2 Lab5 예외처리와 스레드.docx

Microsoft Word - EEL2 Lab5 예외처리와 스레드.docx EEL2 LAB Week 5: 상속 ( 보충 ), 예외처리와스레드 1 Consider using the following Card class public class Card private String name; public Card() name = ""; public Card(String n) name = n; public String getname() return

More information

JVM 메모리구조

JVM 메모리구조 조명이정도면괜찮조! 주제 JVM 메모리구조 설미라자료조사, 자료작성, PPT 작성, 보고서작성. 발표. 조장. 최지성자료조사, 자료작성, PPT 작성, 보고서작성. 발표. 조원 이용열자료조사, 자료작성, PPT 작성, 보고서작성. 이윤경 자료조사, 자료작성, PPT작성, 보고서작성. 이수은 자료조사, 자료작성, PPT작성, 보고서작성. 발표일 2013. 05.

More information

4장.문장

4장.문장 문장 1 배정문 혼합문 제어문 조건문반복문분기문 표준입출력 입출력 형식화된출력 [2/33] ANSI C 언어와유사 문장의종류 [3/33] 값을변수에저장하는데사용 형태 : < 변수 > = < 식 > ; remainder = dividend % divisor; i = j = k = 0; x *= y; 형변환 광역화 (widening) 형변환 : 컴파일러에의해자동적으로변환

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스와메소드심층연구 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 접근제어 class A { private int a; int b; public int c; // 전용 // 디폴트 // 공용 public class Test { public static void main(string args[]) { A obj = new

More information

PowerPoint Presentation

PowerPoint Presentation public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum +

More information

Spring Boot/JDBC JdbcTemplate/CRUD 예제

Spring Boot/JDBC JdbcTemplate/CRUD 예제 Spring Boot/JDBC JdbcTemplate/CRUD 예제 오라클자바커뮤니티 (ojc.asia, ojcedu.com) Spring Boot, Gradle 과오픈소스인 MariaDB 를이용해서 EMP 테이블을만들고 JdbcTemplate, SimpleJdbcTemplate 을이용하여 CRUD 기능을구현해보자. 마리아 DB 설치는다음 URL 에서확인하자.

More information

TEST BANK & SOLUTION

TEST BANK & SOLUTION TEST BANK & SOLUTION 어서와자바는처음이지!" 를강의교재로채택해주셔서감사드립니다. 본문제집을만드는데나름대로노력을기울였으나제가가진지식의한계로말미암아잘못된부분이있을것으로사료됩니다. 잘못된부분을발견하시면 chunik@sch.ac.kr로연락주시면더좋은책을만드는데소중하게사용하겠습니다. 다시한번감사드립니다. 1. 자바언어에서지원되는 8 가지의기초자료형은무엇인가?

More information

11 템플릿적용 - Java Program Performance Tuning (김명호기술이사)

11 템플릿적용 - Java Program Performance Tuning (김명호기술이사) Java Program Performance Tuning ( ) n (Primes0) static List primes(int n) { List primes = new ArrayList(n); outer: for (int candidate = 2; n > 0; candidate++) { Iterator iter = primes.iterator(); while

More information

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드]

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드] - Socket Programming in Java - 목차 소켓소개 자바에서의 TCP 프로그램작성방법 주요클래스와메소드 HTTP 프로토콜을이용한예제 에코프로그램 Q/A 에코프로그램 - EchoServer 에코프로그램 - EchoClient TCP Programming 1 소켓소개 IP, Port, and Socket 포트 (Port): 전송계층에서통신을수행하는응용프로그램을찾기위한주소

More information

PowerPoint Presentation

PowerPoint Presentation Class : Method Jo, Heeseung 목차 section 1 생성자 (Constructor) section 2 생성자오버로딩 (Overloading) section 3 예약어 this section 4 메소드 4-1 접근한정자 4-2 클래스메소드 4-3 final, abstract, synchronized 메소드 4-4 메소드반환값 (return

More information

PowerPoint Presentation

PowerPoint Presentation 자바프로그래밍 1 배열 손시운 ssw5176@kangwon.ac.kr 배열이필요한이유 예를들어서학생이 10 명이있고성적의평균을계산한다고가정하자. 학생 이 10 명이므로 10 개의변수가필요하다. int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; 하지만만약학생이 100 명이라면어떻게해야하는가? int s0, s1, s2, s3, s4,

More information

Microsoft PowerPoint - CSharp-10-예외처리

Microsoft PowerPoint - CSharp-10-예외처리 10 장. 예외처리 예외처리개념 예외처리구문 사용자정의예외클래스와예외전파 순천향대학교컴퓨터학부이상정 1 예외처리개념 순천향대학교컴퓨터학부이상정 2 예외처리 오류 컴파일타임오류 (Compile-Time Error) 구문오류이기때문에컴파일러의구문오류메시지에의해쉽게교정 런타임오류 (Run-Time Error) 디버깅의절차를거치지않으면잡기어려운심각한오류 시스템에심각한문제를줄수도있다.

More information

쉽게 풀어쓴 C 프로그래밊

쉽게 풀어쓴 C 프로그래밊 Power Java 제 27 장데이터베이스 프로그래밍 이번장에서학습할내용 자바와데이터베이스 데이터베이스의기초 SQL JDBC 를이용한프로그래밍 변경가능한결과집합 자바를통하여데이터베이스를사용하는방법을학습합니다. 자바와데이터베이스 JDBC(Java Database Connectivity) 는자바 API 의하나로서데이터베이스에연결하여서데이터베이스안의데이터에대하여검색하고데이터를변경할수있게한다.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 인터페이스 배효철 th1g@nate.com 1 목차 인터페이스의역할 인터페이스선언 인터페이스구현 인터페이스사용 타입변환과다형성 인터페이스상속 디폴트메소드와인터페이스확장 2 인터페이스의역할 인터페이스란? 개발코드와객체가서로통신하는접점 개발코드는인터페이스의메소드만알고있으면 OK 인터페이스의역할 개발코드가객체에종속되지않게 -> 객체교체할수있도록하는역할 개발코드변경없이리턴값또는실행내용이다양해질수있음

More information

. 스레드 (Thread) 란? 스레드를설명하기전에이글에서언급되는용어들에대하여알아보도록하겠습니다. - 응용프로그램 ( Application ) 사용자에게특정서비스를제공할목적으로구현된응용프로그램을말합니다. - 컴포넌트 ( component ) 어플리케이션을구성하는기능별요

. 스레드 (Thread) 란? 스레드를설명하기전에이글에서언급되는용어들에대하여알아보도록하겠습니다. - 응용프로그램 ( Application ) 사용자에게특정서비스를제공할목적으로구현된응용프로그램을말합니다. - 컴포넌트 ( component ) 어플리케이션을구성하는기능별요 . 스레드 (Thread) 란? 스레드를설명하기전에이글에서언급되는용어들에대하여알아보도록하겠습니다. - 응용프로그램 ( Application ) 사용자에게특정서비스를제공할목적으로구현된응용프로그램을말합니다. - 컴포넌트 ( component ) 어플리케이션을구성하는기능별요소로써안드로이드시스템에서는 Activities, Services, Content Providers,

More information

10.0pt1height.7depth.3width±â10.0pt1height.7depth.3widthÃÊ10.0pt1height.7depth.3widthÅë10.0pt1height.7depth.3width°è10.0pt1height.7depth.3widthÇÁ10.0pt1height.7depth.3width·Î10.0pt1height.7depth.3width±×10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width¹Ö pt1height.7depth.3widthŬ10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width½º, 10.0pt1height.7depth.3width°´10.0pt1height.7depth.3widthü, 10.0pt1height.7depth.3widthº¯10.0pt1height.7depth.3width¼ö, 10.0pt1height.7depth.3width¸Þ10.0pt1height.7depth.3width¼Ò10.0pt1height.7depth.3widthµå

10.0pt1height.7depth.3width±â10.0pt1height.7depth.3widthÃÊ10.0pt1height.7depth.3widthÅë10.0pt1height.7depth.3width°è10.0pt1height.7depth.3widthÇÁ10.0pt1height.7depth.3width·Î10.0pt1height.7depth.3width±×10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width¹Ö pt1height.7depth.3widthŬ10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width½º, 10.0pt1height.7depth.3width°´10.0pt1height.7depth.3widthü, 10.0pt1height.7depth.3widthº¯10.0pt1height.7depth.3width¼ö, 10.0pt1height.7depth.3width¸Þ10.0pt1height.7depth.3width¼Ò10.0pt1height.7depth.3widthµå 기초통계프로그래밍 클래스, 객체, 변수, 메소드 hmkang@hallym.ac.kr 금융정보통계학과 강희모 ( 금융정보통계학과 ) 기초통계프로그래밍 1 / 26 자바구성파일 소스파일 소스파일 : 사용자가직접에디터에입력하는파일로자바프로그램언어가제공하는형식으로제작 소스파일의확장자는.java 임 컴파일 : javac 명령어를이용하여프로그래머가만든소스파일을컴파일하여실행파일.class

More information

Microsoft PowerPoint - 2강

Microsoft PowerPoint - 2강 컴퓨터과학과 김희천교수 학습개요 Java 언어문법의기본사항, 자료형, 변수와상수선언및사용법, 각종연산자사용법, if/switch 등과같은제어문사용법등에대해설명한다. 또한 C++ 언어와선언 / 사용방법이다른 Java의배열선언및사용법에대해서설명한다. Java 언어의효과적인활용을위해서는기본문법을이해하는것이중요하다. 객체지향의기본개념에대해알아보고 Java에서어떻게객체지향적요소를적용하고있는지살펴본다.

More information

JMF2_심빈구.PDF

JMF2_심빈구.PDF JMF JSTORM http://wwwjstormpekr Issued by: < > Document Information Document title: Document file name: Revision number: Issued by: JMF2_ doc Issue Date: Status: < > raica@nownurinet

More information

[ 프로젝트이름 ] : Project_Car [ 프로젝트를만든목적 ] : 임의의자동차판매소가있다고가정하고, 고객이원하는자동차의각부분을 Java 를이용하여객 체로생성하고, 그것을제어하는메소드를이용하여자동차객체를생성하는것이목표이다. [ 프로젝트패키지와클래스의내용설명 ] [

[ 프로젝트이름 ] : Project_Car [ 프로젝트를만든목적 ] : 임의의자동차판매소가있다고가정하고, 고객이원하는자동차의각부분을 Java 를이용하여객 체로생성하고, 그것을제어하는메소드를이용하여자동차객체를생성하는것이목표이다. [ 프로젝트패키지와클래스의내용설명 ] [ [ 프로젝트이름 ] : Project_Car [ 프로젝트를만든목적 ] : 임의의자동차판매소가있다고가정하고, 고객이원하는자동차의각부분을 Java 를이용하여객 체로생성하고, 그것을제어하는메소드를이용하여자동차객체를생성하는것이목표이다. [ 프로젝트패키지와클래스의내용설명 ] [Car 패키지 ] : Body, Engine, Seat, Tire, SpeedGauge, Vendor,

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 인터페이스, 람다식, 패키지 손시운 ssw5176@kangwon.ac.kr 인터페이스 인터페이스 (interafce) 는서로다른장치들이연결되어서상호데이터를주 고받는규격을의미한다 2 자바인터페이스 클래스와클래스사이의상호작용의규격을나타낸것이인터페이스이다 3 인터페이스의예 스마트홈시스템 (Smart Home System) 4 인터페이스의정의 public

More information

Spring Data JPA Many To Many 양방향 관계 예제

Spring Data JPA Many To Many 양방향 관계 예제 Spring Data JPA Many To Many 양방향관계예제 오라클자바커뮤니티 (ojc.asia, ojcedu.com) 엔티티매핑 (Entity Mapping) M : N 연관관계 사원 (Sawon), 취미 (Hobby) 는다 : 다관계이다. 사원은여러취미를가질수있고, 하나의취미역시여러사원에할당될수있기때문이다. 보통관계형 DB 에서는다 : 다관계는 1

More information

목차 JEUS EJB Session Bean가이드 stateful session bean stateful sample 가이드 sample source 결과확인 http session에

목차 JEUS EJB Session Bean가이드 stateful session bean stateful sample 가이드 sample source 결과확인 http session에 개념정리및샘플예제 EJB stateful sample 문서 2016. 01. 14 목차 JEUS EJB Session Bean가이드... 3 1. stateful session bean... 3 1.1 stateful sample 가이드... 3 1.1.1 sample source... 3 1.1.2 결과확인... 6 1.2 http session에서사용하기...

More information

Microsoft PowerPoint - chap06-2pointer.ppt

Microsoft PowerPoint - chap06-2pointer.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-2 참고자료 포인터 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 포인터의정의와사용 변수를선언하는것은메모리에기억공간을할당하는것이며할당된이후에는변수명으로그기억공간을사용한다. 할당된기억공간을사용하는방법에는변수명외에메모리의실제주소값을사용하는것이다.

More information

자바 프로그래밍

자바 프로그래밍 5 (kkman@mail.sangji.ac.kr) (Class), (template) (Object) public, final, abstract [modifier] class ClassName { // // (, ) Class Circle { int radius, color ; int x, y ; float getarea() { return 3.14159

More information

Microsoft PowerPoint - 03-TCP Programming.ppt

Microsoft PowerPoint - 03-TCP Programming.ppt Chapter 3. - Socket in Java - 목차 소켓소개 자바에서의 프로그램작성방법 주요클래스와메소드 HTTP 프로토콜을이용한예제 에코프로그램 에코프로그램 - EchoServer 에코프로그램 - EchoClient Q/A 1 1 소켓소개 IP,, and Socket 포트 (): 전송계층에서통신을수행하는응용프로그램을찾기위한주소 소켓 (Socket):

More information

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++,

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++, Level 1은객관식사지선다형으로출제예정 1. 다음은 POST(Post of Sales Terminal) 시스템의한콜레보레이션다이어그램이다. POST 객체의 enteritem(upc, qty) 와 Sale 객체의 makellineitem(spec,qty) 를 Java 또는 C ++, C # 언어로구현하시오. 각메소드구현과관련하여각객체내에필요한선언이있으면선언하시오.

More information

예제 2) Test.java class A intvar= 10; void method() class B extends A intvar= 20; 1"); void method() 2"); void method1() public class Test 3"); args) A

예제 2) Test.java class A intvar= 10; void method() class B extends A intvar= 20; 1); void method() 2); void method1() public class Test 3); args) A 제 10 장상속 예제 1) ConstructorTest.java class Parent public Parent() super - default"); public Parent(int i) this("hello"); super(int) constructor" + i); public Parent(char c) this(); super(char) constructor

More information

오버라이딩 (Overriding)

오버라이딩 (Overriding) WindowEvent WindowEvent 윈도우가열리거나 (opened) 닫힐때 (closed) 활성화되거나 (activated) 비활성화될때 (deactivated) 최소화되거나 (iconified) 복귀될때 (deiconified) 윈도우닫힘버튼을누를때 (closing) WindowEvent 수신자 abstract class WindowListener

More information

Spring Boot

Spring Boot 스프링부트 (Spring Boot) 1. 스프링부트 (Spring Boot)... 2 1-1. Spring Boot 소개... 2 1-2. Spring Boot & Maven... 2 1-3. Spring Boot & Gradle... 3 1-4. Writing the code(spring Boot main)... 4 1-5. Writing the code(commandlinerunner)...

More information

untitled

untitled - -, (insert) (delete) - - (insert) (delete) (top ) - - (insert) (rear) (delete) (front) A A B top A B C top push(a) push(b) push(c) A B top pop() top A B D push(d) top #define MAX_STACK_SIZE 100 int

More information

Microsoft PowerPoint - 14주차 강의자료

Microsoft PowerPoint - 14주차 강의자료 Java 로만드는 Monster 잡기게임예제이해 2014. 12. 2 게임화면및게임방법 기사초기위치 : (0,0) 아이템 10 개랜덤생성 몬스터 10 놈랜덤생성 Frame 하단에기사위치와기사파워출력방향키로기사이동아이템과몬스터는고정종료버튼클릭하면종료 Project 구성 GameMain.java GUI 환경설정, Main Method 게임객체램덤위치에생성 Event

More information

슬라이드 1

슬라이드 1 UNIT 07 조건문과반복문 로봇 SW 교육원 3 기 학습목표 2 조건문을사용핛수있다. 반복문을사용핛수있다. 조건문 3 조건식의연산결과에따라프로그램의실행흐름을변경 조건문의구성 조건식 실행될문장 조건문의종류 if switch? : ( 삼항연산자 ) if 조건문 4 if 문의구성 조건식 true 또는 false(boolean 형 ) 의결과값을갖는수식 실행될문장

More information

5장.key

5장.key JAVA Programming 1 (inheritance) 2!,!! 4 3 4!!!! 5 public class Person {... public class Student extends Person { // Person Student... public class StudentWorker extends Student { // Student StudentWorker...!

More information

JUNIT 실습및발표

JUNIT 실습및발표 JUNIT 실습및발표 JUNIT 접속 www.junit.org DownLoad JUnit JavaDoc API Document 를참조 JUNIT 4.8.1 다운로드 설치파일 (jar 파일 ) 을다운로드 CLASSPATH 를설정 환경변수에서설정 실행할클래스에서 import JUnit 설치하기 테스트실행주석 @Test Test 를실행할 method 앞에붙임 expected

More information

No Slide Title

No Slide Title 클래스와객체 이충기 명지대학교컴퓨터공학과 들어가며 Q: 축구게임에서먼저공격하는팀을정하기위해동전을던진다. 우리는동전을던질때앞면이나오느냐아니면뒷면이나오느냐에만관심이있다. 또한동전을가지고해야할일은동전을던지는것과동전을던진후결과를알면된다. 이동전을효과적으로나타낼수있는방법을기술하라. A: 2 클래스와객체 객체 (object): 우리주변의어떤대상의모델이다. - 예 : 학생,

More information

JAVA PROGRAMMING 실습 02. 표준 입출력

JAVA PROGRAMMING 실습 02. 표준 입출력 자바의기본구조? class HelloJava{ public static void main(string argv[]){ system.out.println( hello,java ~ ){ } } # 하나하나뜯어살펴봅시다! public class HelloJava{ 클래스정의 public static void main(string[] args){ System.out.println(

More information

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 19 장배치관리자 이번장에서학습할내용 배치관리자의개요 배치관리자의사용 FlowLayout BorderLayout GridLayout BoxLayout CardLayout 절대위치로배치 컨테이너안에서컴포넌트를배치하는방법에대하여살펴봅시다. 배치관리자 (layout manager) 컨테이너안의각컴포넌트의위치와크기를결정하는작업 [3/70] 상당히다르게보인다.

More information