PowerPoint 프레젠테이션

Size: px
Start display at page:

Download "PowerPoint 프레젠테이션"

Transcription

1 명품 JAVA Essential 1

2 2 학습목표 1. 패키지개념이해 2. 사용자패키지만들기 3. 자바에서제공하는표준패키지 4. Object 클래스활용 5. 박싱 / 언박싱을이해하고 Wrapper 클래스활용 6. String과 StringBuffer 클래스활용 7. StringTokenizer 클래스활용 8. Math 클래스활용

3 패키지개념과필요성 3 * 3 명이분담하여자바응용프로그램을개발하는경우, 동일한이름의클래스가존재할가능성있음 -> 합칠때오류발생가능성 -> 개발자가서로다른디렉터리로코드관리하여해결

4 개발자가서로다른디렉터리로코드관리 4 이름은같지만경로명이달라서도다른파일로취급

5 자바패키지 5 패키지 (package) 서로관련된클래스와인터페이스를컴파일한클래스파일들을묶어놓은디렉터리 하나의응용프로그램은한개이상의패키지로작성 패키지는 jar 파일로압축할수있음 JDK 에서제공하는표준패키지는 rt.jar 에압축 클래스경로명 패키지이름과 클래스이름으로완성 클래스의이름 ( 경로명 ) java.awt.color 패키지명

6 자바표준패키지와클래스경로명 6 rt.jar 클래스의이름 ( 경로명 ) java.awt.color 패키지명 패키지명 : java.awt java.awt 패키지에속한클래스

7 패키지사용하기, import 문 7 다른패키지에작성된클래스사용 import 를이용하지않는경우 소스에클래스이름의완전경로명사용 public class ImportExample { public static void main(string[] args) { java.util.scanner scanner = new java.util.scanner(system.in); 필요한클래스만 import 소스시작부분에클래스의경로명 import import 패키지. 클래스 소스에는클래스명만명시하면됨 패키지전체를 import 소스시작부분에패키지의경로명.* import import 패키지.* 소스에는클래스명만명시하면됨 import java.util.*; java.util 패키지내의모든클래스만을지정, 하위패키지의클래스는포함하지않음 import java.util.scanner; public class ImportExample { public static void main(string[] args) { Scanner scanner = new Scanner(System.in); import java.util.*; public class ImportExample { public static void main(string[] args) { Scanner scanner = new Scanner(System.in);

8 패키지만들기 8 클래스파일 (.class) 이저장되는위치는? 클래스나인터페이스가컴파일되면클래스파일 (.class) 생성 클래스파일은패키지로선언된디렉터리에저장 패키지선언 소스파일의맨앞에컴파일후저장될패키지지정 package 패키지명 ; package UI; // 아래 Tools 를컴파일하여 UI 패키지 (UI 디렉토리 ) 에저장할것지시 public class Tools {... Tools 클래스의경로명은 UI.Tools 가됨 package Graphic; // 아래 Line 클래스를 Graphic 패키지에저장 import UI.Tools; // UI.Tools 클래스의경로명임포트 public class Line extends Shape { public void draw() { Tools t = new Tools();

9 디폴트패키지 9 package 선언문이없는자바소스파일의경우 컴파일러는클래스나인터페이스를디폴트패키지에소속시킴 디폴트패키지 현재디렉터리

10 이클립스로쉽게패키지만들기 10 예제로사용할샘플소스 (5 장의예제 5-5) abstract class Calculator { public abstract int add(int a, int b); public abstract int subtract(int a, int b); public abstract double average(int[] a); lib 패키지에 class GoodCalc extends Calculator { app 패키지에 public int add(int a, int b) { return a+b; public int subtract(int a, int b) { return a - b; public double average(int[] a) { double sum = 0; for (int i = 0; i < a.length; i++) sum += a[i]; return sum/a.length; public static void main(string [] args) { Calculator c = new GoodCalc(); System.out.println(c.add(2,3)); System.out.println(c.subtract(2,3)); System.out.println(c.average(new int [] {2,3,4 )); Calculator 클래스는 lib 패키지에 GoodCalc 클래스는 app 패키지에나누어저장하는응용프로그램을이클립스를이용하여만들기

11 11 프로젝트작성 ( 프로젝트이름 : PackageEx)

12 12 패키지 lib 작성

13 13 패키지 app 작성

14 패키지작성이완료된결과 패키지탐색창에 app 패키지와 lib 패키지가보인다. 14

15 lib 패키지에클래스 Calculator 만들기 Calculator 클래스를 public abstract 속성으로생성한다. 15

16 Calculator 소스작성후수정 주목 다른패키지, 즉 app 패키지의클래스에서접근할수있도록하기위해클래스의접근지정자 public 을반드시삽입. 16

17 app 패키지에 GoodCalc.java 작성후수정 import 문삽입. Calculator 클래스를사용하기위해서는패키지를포함하는정확한경로명을컴파일러에게알려줘야함. 17

18 푸시다운버튼을누르면아래메뉴가보인다. 실행을위한 Run Configurations 작성 main() 메소드를가진클래스를지정한다. 18

19 19 프로젝트 PackageEx 실행

20 JDK 표준자바패키지구조 : rt.jar java applet awt beans io lang math net nio rmi security sql text util beancontext spi color datatransfer dnd event font geom im image print channels charset spi renderable spi spi annotation instrument management ref reflect activation dgc registry server acl cert spec interfaces concurren t jar logging prefs regex spi zip 20 atomic locks

21 JDK 의주요패키지 21 java.lang 스트링, 수학함수, 입출력등자바프로그래밍에필요한기본적인클래스와인터페이스 자동으로 import 됨 - import 문필요없음 java.util 날짜, 시간, 벡터, 해시맵등과같은다양한유틸리티클래스와인터페이스제공 java.io 키보드, 모니터, 프린터, 디스크등에입출력을할수있는클래스와인터페이스제공 java.awt GUI 프로그램을작성하기위한 AWT 패키지 javax.swing GUI 프로그래밍을작성하기위한스윙패키지

22 Object 클래스 22 특징 모든자바클래스는반드시 Object 를상속받도록자동컴파일 모든클래스의수퍼클래스 모든클래스가상속받는공통메소드포함 주요메소드

23 객체속성 23 Object 클래스는객체의속성을나타내는메소드제공 hashcode() 메소드 객체의해시코드값을리턴하며, 객체마다다름 getclass() 메소드 객체의클래스정보를담은 Class 객체리턴 Class 객체의 getname() 메소드는객체의클래스이름리턴 tostring() 메소드 객체를문자열로리턴

24 예제 6-1 : Object 클래스로객체속성알아내기 24 Object 클래스를이용하여객체의클래스명, 해시코드값, 객체의문자열을출력해보자. class Point { int x, y; public Point(int x, int y) { this.x = x; this.y = y; public class ObjectPropertyEx { public static void main(string [] args) { Point p = new Point(2,3); System.out.println(p.getClass().getName()); // 클래스이름 System.out.println(p.hashCode()); // 해시코드값 System.out.println(p.toString()); // 객체의문자열 Point Point@153f67e 해시코드의 16 진수값. 이값은실행할때마다달라질수있음.

25 tostring() 메소드, 객체를문자열로변환 25 각클래스는 tostring() 을오버라이딩하여자신만의문자열리턴가능 객체를문자열로반환원형 public String tostring(); 컴파일러에의한 tostring() 자동변환 객체 + 문자열 -> 객체.toString() + 문자열 로자동변환객체를단독으로사용하는경우 -> 객체.toString() 으로자동변환 Point a = new Point(2,3); String s = a + " 점 "; System.out.println(s); 자동변환 자동변환 Point a = new Point(2,3); String s = a.tostring()+ " 점 "; System.out.println(s.toString());

26 예제 6-2 : Point 클래스에 tostring() 작성 26 Point 클래스에 Point 객체를문자열로리턴하는 tostring() 메소드를작성하라. class Point { int x, y; public Point(int x, int y) { this.x = x; this.y = y; public String tostring() { return "Point(" + x + "," + y + ")"; public class ToStringEx { public static void main(string [] args) { Point a = new Point(2,3); System.out.println(a.toString()); System.out.println(a); // a 는 a.tostring() 으로자동변환됨 Point(2,3) Point(2,3)

27 객체비교 (==) 와 equals() 메소드 27 == 연산자 객체레퍼런스비교 Point a = new Point(2,3); Point b = new Point(2,3); Point c = a; if(a == b) // false System.out.println("a==b"); if(a == c) // true System.out.println("a==c"); a==c boolean equals(object obj) 두객체의내용물비교객체의내용물을비교하기위해클래스의멤버로작성

28 예제 6-3 : Point 클래스의 equals() 작성 28 Point 클래스에 x, y 점좌표가같으면 true를리턴하는 equals() 를작성하라. class Point { int x, y; public Point(int x, int y) { this.x = x; this.y = y; public boolean equals(point p) { if(x == p.x && y == p.y) return true; else return false; 이 Point 객체와객체 p 가같은지비교 public class EqualsEx { public static void main(string[] args) { Point a = new Point(2,3); Point b = new Point(2,3); Point c = new Point(3,4); if(a == b) System.out.println("a==b"); if(a.equals(b)) System.out.println("a is equal to b"); if(a.equals(c)) System.out.println("a is equal to c"); a is equal to b

29 예제 6-4 : Rect 클래스와 equals() 메소드만들기연습 29 int 타입의 width( 너비 ), height( 높이 ) 필드를가지는 Rect 클래스를작성하고, 면적이같으면두 Rect 객체가같은것으로판별하는 equals() 를작성하라. class Rect { int width, height; public Rect(int width, int height) { this.width = width; this.height = height; public boolean equals(rect p) { if (width*height == p.width*p.height) return true; else return false; public class RectEx { public static void main(string[] args) { Rect a = new Rect(2,3); // 면적 6 Rect b = new Rect(3,2); // 면적 6 Rect c = new Rect(3,4); // 면적 12 이사각형과객체 p 의면적비교 if(a.equals(b)) System.out.println("a is equal to b"); if(a.equals(c)) System.out.println("a is equal to c"); if(b.equals(c)) System.out.println("b is equal to c"); a is equal to b a 와 b 는면적이같으므로 equals() 는같다고판단

30 Wrapper 클래스 30 Wrapper 클래스 자바의기본타입을클래스화한 8 개클래스를통칭 용도 객체만사용할수있는컬렉션등에기본타입의값을사용하기위해 -> Wrapper 객체로만들어사용

31 Wrapper 클래스의객체생성 31 Wrapper 객체로생성하는방법 Integer i = new Integer(10); Character c = new Character('c'); Boolean b = new Boolean(true); Boolean b = new Boolean("false"); Integer I = new Integer("10"); Double d = new Double("3.14");

32 주요메소드 32 가장많이사용하는 Integer 클래스의주요메소드 다른 Wrapper 클래스의메소드는이와유사

33 Wrapper 클래스의활용 33 Wrapper 객체에들어있는기본타입값알아내기 Integer i = new Integer(10); int ii = i.intvalue(); // ii = 10 Character c = new Character('c'); char cc = c.charvalue(); // cc = 'c' Boolean b = new Boolean(true); boolean bb = b.booleanvalue(); // bb = true 문자열을기본타입으로변환 int i = Integer.parseInt("123"); // i = 123 boolean b = Boolean.parseBoolean("true"); // b = true double d = Double.parseDouble(" "); // d = 기본타입값을문자열로변환 String s1 = Integer.toString(123); String s2 = Integer.toHexString(123); String s3 = Double.toString(3.14); String s4 = Charater.toString('a'); String s5 = Boolean.toString(true); // 정수 123을문자열 "123" 으로변환 // 정수 123을 16진수의문자열 "7b" 로변환 // 실수 를문자열 " " 로변환 // 문자 a 를문자열 "a" 로변환 // 불린값 true를문자열 "true" 로변환

34 예제 6-5 : Wrapper 클래스활용 34 다음은 Wrapper 클래스를활용하는예이다. 다음프로그램의결과는무엇인가? public class WrapperEx { public static void main(string[] args) { // Character 사용 System.out.println(Character.toLowerCase('A')); // 'A' 를소문자로변환 char c1='4', c2='f'; if(character.isdigit(c1)) // 문자 c1 이숫자이면 true System.out.println(c1 + " 는숫자 "); if(character.isalphabetic(c2)) // 문자 c2 가영문자이면 true System.out.println(c2 + " 는영문자 "); // Integer 사용 System.out.println(Integer.parseInt("28")); // 문자열 "28" 을 10 진수로변환 System.out.println(Integer.toString(28)); // 정수 28 을 2 진수문자열로변환 System.out.println(Integer.toBinaryString(28)); // 28 을 16 진수문자열로변환 System.out.println(Integer.bitCount(28)); // 28 에대한 2 진수의 1 의개수 Integer i = new Integer(28); System.out.println(i.doubleValue()); // 정수를 double 값으로변환 // Double 사용 Double d = new Double(3.14); System.out.println(d.toString()); // Double 을문자열 "3.14" 로변환 System.out.println(Double.parseDouble("3.14")); // 문자열을실수 3.14 로변환 // Boolean 사용 boolean b = (4>3); // b 는 true System.out.println(Boolean.toString(b)); // true 를문자열 "true" 로변환 System.out.println(Boolean.parseBoolean("false")); // 문자열을 false 로변환 a 4 는숫자 F 는영문자 true false

35 박싱과언박싱 35 박싱 (boxing) 기본타입의값을 Wrapper 객체로변환하는것 언박싱 (unboxing) Wrapper 객체에들어있는기본타입의값을빼내는것 박싱의반대 자동박싱과자동언박싱 JDK 1.5 부터박싱과언박싱은자동으로이루어지도록컴파일됨 Integer ten = 10; int n = ten; // 자동박싱. Integer ten = new Integer(10); 과동일 // 자동언박싱. int n = ten.intvalue(); 와동일

36 String 의생성과특징 36 String String 클래스는문자열을나타냄 스트링리터럴 ( 문자열리터럴 ) 은 String 객체로처리됨 스트링객체의생성사례 String str1 = "abcd"; char data[] = {'a', 'b', 'c', 'd'; String str2 = new String(data); String str3 = new String("abcd"); // str2 와 str3 은모두 "abcd" 스트링

37 스트링리터럴과 new String() 37 스트링리터럴 자바가상기계내부에서리터럴테이블에저장되고관리됨응용프로그램에서공유됨 스트링리터럴사례 ) String s = "Hello"; new String() 으로생성된스트링 스트링객체는힙에생성스트링은공유되지않음

38 스트링객체의주요특징 38 스트링객체는수정불가능 리터럴스트링이든 new String() 을생성했든객체의문자열수정불가능 예 ) String s = new String("Hello"); String t = s.concat("java"); // s의스트링은수정불가능 // 스트링 s에 "Java" 를덧붙인스트링리턴 스트링비교 두스트링을비교할때반드시 equals() 를사용하여야함 equals() 는내용을비교하기때문

39 39 주요메소드

40 String 활용 40 스트링비교, int compareto(string anotherstring) 문자열이같으면 0 리턴 이문자열이 anotherstring 보다사전에먼저나오면음수리턴 이문자열이 anotherstring 보다사전에나중에나오면양수리턴 String java= "Java"; String cpp = "C++"; int res = java.compareto(cpp); if(res == 0) System.out.println("the same"); else if(res < 0) System.out.println(java + " < " + cpp); else System.out.println(java + " > " + cpp); Java > C++ "java" 가 "C++" 보다사전에나중에나오기때문에양수리턴 공백제거, String trim() 키보드나파일로부터스트링을입력시, 스트링앞뒤공백이끼는경우가많다. -> trim() 을이용하면스트링앞뒤에있는공백제거 String a = " xyz\t"; String b = a.trim(); // b = "xyz". 빈칸과 '\t' 제거됨

41 예제 6-6 : String 을활용하여문자열다루기 41 public class StringEx { public static void main(string[] args) { String a = new String(" C#"); String b = new String(",C++ "); 3 System.out.println(a + " 의길이는 " + a.length()); // 문자열의길이 ( 문자개수 ) System.out.println(a.contains("#")); // 문자열의포함관계 true a = a.concat(b); // 문자열연결 System.out.println(a); a = a.trim(); // 문자열앞뒤의공백제거 System.out.println(a); a = " C#, C++ " a = "C#,C++" a = a.replace("c#","java"); // 문자열대치 System.out.println(a); a = "Java,C++" String s[] = a.split(","); // 문자열분리 s[0] = "Java" for (int i=0; i<s.length; i++) s[1] = "C++" System.out.println(" 분리된문자열 " + i + ": " + s[i]); a = a.substring(5); // 인덱스 5 부터끝까지서브스트링리턴 System.out.println(a); char c = a.charat(2); // 인덱스 2 의문자리턴 System.out.println(c); + a = "C++" C# 의길이는 3 true C#,C++ C#,C++ Java,C++ 분리된문자열 0: Java 분리된문자열 1: C++ C++ +

42 StringBuffer 클래스 42 가변스트링을다루는클래스 StringBuffer 객체생성 StringBuffer sb = new StringBuffer("java"); String 클래스와달리문자열변경가능 가변크기의버퍼를가지고있어문자열수정가능 문자열의수정이많은작업에적합 스트링조작사례 StringBuffer sb = new StringBuffer("This"); sb.append(" is pencil."); sb.insert(7, " my"); sb.replace(8, 10, "your"); System.out.println(sb); // sb = "This is pencil." // sb = "This is my pencil." // sb = "This is your pencil." // "This is your pencil." 출력

43 StringTokenizer 클래스 43 구분문자를기준으로문자열을분리하는클래스 예 ) 구분문자 (delimiter) : 문자열을구분할때사용되는문자 토큰 (token) : 구분문자로분리된문자열 구문문자 '&' int count = st.counttokens(); String token = st.nexttoken(); 토큰개수알아내기. count = 3 다음토큰얻어내기. st = "name=kitae"

44 StringTokenizer 로문자열분리사례 44 구문문자는 2 개 '&' 와 '=' int count = st.counttokens(); String token = st.nexttoken(); 토큰개수알아내기. count = 6 다음토큰얻어내기. st = "name"

45 예제 6-7 : StringTokenizer 를이용한문자열분리 45 "name=kitae&addr=seoul&age=21" 를 '&' 문자를기준으로분리하는코드를작성하라. import java.util.stringtokenizer; public class StringTokenizerEx { public static void main(string[] args) { String query = "name=kitae&addr=seoul&age=21"; StringTokenizer st = new StringTokenizer(query, "&"); int n = st.counttokens(); // 분리된토큰개수 System.out.println(" 토큰개수 = " + n); while(st.hasmoretokens()) { String token = st.nexttoken(); System.out.println(token); // 토큰얻기 // 토큰출력 토큰개수 = 3 name=kitae addr=seoul age=21

46 Math 클래스 46 기본산술연산메소드를제공하는클래스 모든메소드는 static 으로선언 클래스이름으로호출가능 Math.random() 메소드로난수발생 random() 은 0 보다크거나같고 1.0 보다작은실수난수발생 1 에서 100 까지의랜덤정수 10 개를발생시키는코드사례 for(int x=0; x<10; x++) { int n = (int)(math.random()* ); // 1~100 까지의랜덤정수발생 System.out.println(n); * java.util.random 클래스를이용하여난수발생가능 Random r = new Random(); int n = r.nextint(); // 음수, 양수, 0 포함, 자바의정수범위난수발생 int m = r.nextint(100); // 0에서 99 사이 (0과 99 포함 ) 의정수난수발생

47 예제 6-8 : Math 클래스활용 47 Math 클래스의메소드활용예를보인다. public class MathEx { public static void main(string[] args) { System.out.println(Math.abs(-3.14)); // 절댓값구하기 System.out.println(Math.sqrt(9.0)); // 9의제곱근 = 3 System.out.println(Math.exp(2)); // e 2 System.out.println(Math.round(3.14)); // 반올림 // [1, 45] 사이의정수형난수 5 개발생 System.out.print(" 이번주행운의번호는 "); for (int i=0; i<5; i++) System.out.print((int)(Math.random()*45 + 1) + " "); // 난수발생 이번주행운의번호는

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 패키지개념이해 2. 사용자패키지만들기 3. 자바에서제공하는표준패키지 4. Object 클래스활용 5. 박싱 / 언박싱을이해하고 Wrapper 클래스활용 6. String과 StringBuffer 클래스활용 7. StringTokenizer 클래스활용 8. Math 클래스활용 1 패키지개념과필요성 3 * 3

More information

6장.key

6장.key JAVA Programming 1 2 3, -> () 3 Project FileIO WebFile.class FileCopy.class FileRW.class Tools.class Graphic DObject.class Line.class Rect.class Circle.class Project/FileIO/Tools.class Project/UI/Tools.class

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 패키지와모듈개념이해 2. 사용자패키지만들기 3. 자바에서제공하는표준패키지 4. Object 클래스활용 5. 박싱 / 언박싱을이해하고 Wrapper 클래스활용 6. String과 StringBuffer 클래스활용 7. StringTokenizer 클래스활용 8. Math 클래스활용 패키지개념과필요성 3 *

More information

<4D F736F F F696E74202D205B4A415641C7C1B7CEB1D7B7A1B9D65D36C0E5C6D0C5B0C1F6>

<4D F736F F F696E74202D205B4A415641C7C1B7CEB1D7B7A1B9D65D36C0E5C6D0C5B0C1F6> 명품 JAVA Programming 1 제 6 장패키지개념과자바기본패키지 패키지개념과필요성 2 3명이분담하여자바응용프로그램을개발하는경우, 동일한이름의클래스가존재할가능성있음 -> 합칠때오류발생 디렉터리로각개발자의코드관리 ( 패키지 ) 3 Project FileIO Graphic WebFile.class FileCopy.class FileRW.class Tools.class

More information

Microsoft PowerPoint - java1-lecture7.ppt [호환 모드]

Microsoft PowerPoint - java1-lecture7.ppt [호환 모드] 패키지개념과필요성 패키지 3명이분담하여자바응용프로그램을개발하는경우, 동일한이름의클래스가존재할가능성있음 -> 합칠때오류발생 514760-1 2017 년가을학기 10/30/2017 박경신 디렉터리로각개발자의코드관리 ( 패키지 ) 자바의패키지 (package) Project FileIO Graphic WebFile.class FileCopy.class FileRW.class

More information

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

Microsoft PowerPoint - java2-lecture5.ppt [호환 모드] 모듈 모듈, 패키지 Java 9 Module System Project Jigsaw Modular JDK Modular Java Source Code Modular Run-time Images Encapsulate Java Internal APIs 514770 2018 년가을학기 10/15/2018 박경신 Java Platform Module System 편하고효율적인

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

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

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 목차 인스턴스멤버와 this 객체의소멸과가비지 정적멤버와 static final 필드와상수 패키지 접근제한자 Getter와 Setter 2 목차 인스턴스멤버와 this 객체의소멸과가비지 정적멤버와 static final 필드와상수 패키지 접근제한자 Getter와 Setter 3 인스턴스멤버와 this 인스턴스멤버란?

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 클래스 ( 계속 ) 배효철 th1g@nate.com 1 목차 인스턴스멤버와 this 객체의소멸과가비지 정적멤버와 static final 필드와상수 패키지 접근제한자 Getter와 Setter 2 목차 인스턴스멤버와 this 객체의소멸과가비지 정적멤버와 static final 필드와상수 패키지 접근제한자 Getter와 Setter 3 인스턴스멤버와 this 인스턴스멤버란?

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

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 Power Java 제 20 장패키지 이번장에서학습할내용 패키지의개념 패키지로묶는방법 패키지사용 기본패키지 유틸리티패키지 패키지는연관된클래스들을묶는기법입니다. 패키지란? 패키지 (package) : 클래스들을묶은것 자바라이브러리도패키지로구성 ( 예 ) java.net 패키지 네트워크관련라이브러리 그림 20-1. 패키지의개념 예제 패키지생성하기 Q: 만약패키지문을사용하지않은경우에는어떻게되는가?

More information

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

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

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

PowerPoint 프레젠테이션

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

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

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

(Microsoft PowerPoint - java2-lecture2.ppt [\310\243\310\257 \270\360\265\345]) Array 기초문법배열, 문자열, 입출력 514770-1 2017 년봄학기 3/22/2017 박경신 배열 (array) 여러개의데이터를같은이름으로활용할수있도록해주는자료구조 인덱스 (Index, 순서번호 ) 와인덱스에대응하는데이터들로이루어진자료구조 배열을이용하면한번에많은메모리공간선언가능 배열은같은타입의데이터들이순차적으로저장되는공간 원소데이터들이순차적으로저장됨

More information

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

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

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

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 2 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

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

Microsoft PowerPoint - java1-lecture6.ppt [호환 모드] 실세계의인터페이스와인터페이스의필요성 인터페이스, 람다식, 패키지 514760-1 2016 년가을학기 10/13/2016 박경신 정해진규격 ( 인터페이스 ) 에맞기만하면연결가능. 각회사마다구현방법은다름 정해진규격 ( 인터페이스 ) 에맞지않으면연결불가 인터페이스의필요성 인터페이스를이용하여다중상속구현 자바에서클래스다중상속불가 인터페이스는명세서와같음 인터페이스만선언하고구현을분리하여,

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

Microsoft PowerPoint - lec7_package [호환 모드]

Microsoft PowerPoint - lec7_package [호환 모드] Lecture 7: Package 패키지의선언 패키지의사용 JAR 파일 자바의언어패키지 2 연관된클래스나인터페이스를하나의단위로묶는방법 장점 여러개의클래스와인터페이스를하나의그룹으로다루는수단을제공 클래스이름사이의충돌문제를해결 패키지의종류 기본패키지 : java.lang, java.util, java.io, java.awt 사용자정의패키지 3 선언형태 package

More information

Microsoft PowerPoint - 2강

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

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스, 객체, 메소드 손시운 ssw5176@kangwon.ac.kr 실제세계는객체로이루어진다. 2 객체와메시지 3 객체지향이란? 실제세계를모델링하여소프트웨어를개발하는방법 4 객체 5 객체란? 객체 (Object) 는상태와동작을가지고있다. 객체의상태 (state) 는객체의특징값 ( 속성 ) 이다. 객체의동작 (behavior) 또는행동은객체가취할수있는동작

More information

07 자바의 다양한 클래스.key

07 자바의 다양한 클래스.key [ 07 ] . java.lang Object, Math, String, StringBuffer Byte, Short, Integer, Long, Float, Double, Boolean, Character. java.util Random, StringTokenizer Calendar, GregorianCalendar, Date. Collection, List,

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

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

JAVA PROGRAMMING 실습 09. 예외처리

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

More information

Microsoft PowerPoint - java1-lecture5.ppt [호환 모드]

Microsoft PowerPoint - java1-lecture5.ppt [호환 모드] 상속 (Inheritance) 객체지향개념상속, 추상클래스, 다형성 514760-1 2016 년가을학기 10/06/2016 박경신 상속 상위클래스의특성 ( 필드, 메소드 ) 을하위클래스에물려주는것 슈퍼클래스 (superclass) 특성을물려주는상위클래스 서브클래스 (subclass) 특성을물려받는하위클래스 슈퍼클래스에자신만의특성 ( 필드, 메소드 ) 추가 슈퍼클래스의특성

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

슬라이드 1

슬라이드 1 UNIT 12 상속과오버라이딩 로봇 SW 교육원 2 기 최상훈 학습목표 2 클래스를상속핛수있다. 메소드오버라이딩을사용핛수있다. 패키지선언과 import 문을사용핛수있다. 상속 (inheritance) 3 상속이란 기존의클래스를기반으로새로운클래스를작성 두클래스를부모와자식으로관계를맺어주는것 자식은부모의모든멤버를상속받음 연관된일렦의클래스에대핚공통적인규약을정의 class

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 - java2-lecture3.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - java2-lecture3.ppt [\310\243\310\257 \270\360\265\345]) Class Class, Collections 514770-1 2017 년봄학기 3/22/2017 박경신 클래스 (Class) 객체의속성과행위선언 객체의설계도혹은틀 객체 (Object) 클래스의틀로찍어낸실체 메모리공간을갖는구체적인실체 클래스를구체화한객체를인스턴스 (instance) 라고부름 객체와인스턴스는같은뜻으로사용 클래스구조 클래스접근권한, public 다른클래스들에서이클래스를사용하거나접근할수있음을선언

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 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

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

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 - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx #include int main(void) { int num; printf( Please enter an integer "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 을 작성하면서 C 프로그램의

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

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 Power Java 제 7 장클래스와객체 이번장에서학습할내용 객체지향이란? 객체 메시지 클래스 객체지향의장점 String 클래스 객체지향개념을완벽하게이해해야만객체지향설계의이점을활용할수있다. 실제세계는객체로이루어진다. 객체지향이란? 실제세계를모델링하여소프트웨어를개발하는방법 절차지향과객체지향 절차지향프로그래밍 (procedural programming): 문제를해결하는절차를중요하게생각하는방법

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

쉽게

쉽게 Power Java 제 4 장자바프로그래밍기초 이번장에서학습할내용 자바프로그램에대한기초사항을학습 자세한내용들은추후에. Hello.java 프로그램 주석 주석 (comment): 프로그램에대한설명을적어넣은것 3 가지타입의주석 클래스 클래스 (class): 객체를만드는설계도 ( 추후에학습 ) 자바프로그램은클래스들로구성된다. 그림 4-1. 자바프로그램의구조 클래스정의

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

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

쉽게 풀어쓴 C 프로그래밍

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

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 상속 배효철 th1g@nate.com 1 목차 상속개념 클래스상속 부모생성자호출 메소드재정의 final 클래스와 final 메소드 protected 접근제한자 타입변환과다형성 추상클래스 2 상속개념 상속 (Inheritance) 이란? 현실세계 : 부모가자식에게물려주는행위 부모가자식을선택해서물려줌 객체지향프로그램 : 자식 ( 하위, 파생 ) 클래스가부모 (

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 자바프로그래밍 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

(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

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 프레젠테이션 @ 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

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 5 장생성자와접근제어 1. 객체지향기법을이해한다. 2. 클래스를작성할수있다. 3. 클래스에서객체를생성할수있다. 4. 생성자를이용하여객체를초기화할수 있다. 5. 접근자와설정자를사용할수있다. 이번장에서만들어볼프로그램 생성자 생성자 (constructor) 는초기화를담당하는함수 생성자가필요한이유 #include using namespace

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Lecture 02 프로그램구조및문법 Kwang-Man Ko kkmam@sangji.ac.kr, compiler.sangji.ac.kr Department of Computer Engineering Sang Ji University 2018 자바프로그램기본구조 Hello 프로그램구조 sec01/hello.java 2/40 자바프로그램기본구조 Hello 프로그램구조

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

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

09-interface.key

09-interface.key 9 Database insert(record r): boolean find(key k): Record 1 Record getkey(): Key * Record Key Database.? Key equals(key y): boolean Database insert(record r): boolean find(key k): Record * Database OK 1

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

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

C++ Programming

C++ Programming C++ Programming 연산자다중정의 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 연산자다중정의 C++ 스타일의문자열 2 연산자다중정의 연산자다중정의 단항연산자다중정의 이항연산자다중정의 cin, cout 그리고 endl C++ 스타일의문자열 3 연산자다중정의 연산자다중정의 (Operator

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Lab 4 ADT Design 클래스로정의됨. 모든객체들은힙영역에할당됨. 캡슐화 (Encapsulation) : Data representation + Operation 정보은닉 (Information Hiding) : Opertion부분은가려져있고, 사용자가 operation으로만사용가능해야함. 클래스정의의형태 public class Person { private

More information

1. 자바프로그램기초 및개발환경 2 장 & 3 장. 자바개발도구 충남대학교 컴퓨터공학과

1. 자바프로그램기초 및개발환경 2 장 & 3 장. 자바개발도구 충남대학교 컴퓨터공학과 1. 자바프로그램기초 및개발환경 2 장 & 3 장. 자바개발도구 충남대학교 컴퓨터공학과 학습내용 1. Java Development Kit(JDK) 2. Java API 3. 자바프로그래밍개발도구 (Eclipse) 4. 자바프로그래밍기초 2 자바를사용하려면무엇이필요한가? 자바프로그래밍개발도구 JDK (Java Development Kit) 다운로드위치 : http://www.oracle.com/technetwork/java/javas

More information

Microsoft Word - PJ_scjp_9_0_1-lang.doc

Microsoft Word - PJ_scjp_9_0_1-lang.doc SCJP 강좌 Section 9 java.lang package 문서정보 문서제목 scjp 강좌 : Section 9 java.lang package 파일이름 PJ_scjp_9_0_1.pdf 작성자 신상훈, 김병필 작성일 2002년 1월 10일 버전 0.1 상태 초안 내용정보 예상독자개요 페이지 scjp 취득을원하는 java 초보 java.lang 패키지의

More information

PowerPoint 프레젠테이션

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

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

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx 2018 학년도 1 학기 JAVA 프로그래밍 II 514760-1 2018 년봄학기 5/10/2018 박경신 Lab#1 (ImageTest) Lab#1 은영상파일 (Image) 을읽어서정보를출력 Java Tutorials Lesson: Working with Images https://docs.oracle.com/javase/tutorial/2d/images/index.html

More information

슬라이드 1

슬라이드 1 UNIT 6 배열 로봇 SW 교육원 3 기 학습목표 2 배열을사용핛수있다. 배열 3 배열 (Array) 이란? 같은타입 ( 자료형 ) 의여러변수를하나의묶음으로다루는것을배열이라고함 같은타입의많은양의데이터를다룰때효과적임 // 학생 30 명의점수를저장하기위해.. int student_score1; int student_score2; int student_score3;...

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 객체지향상속과자바상속개념이해 2. 클래스상속작성및객체생성 3. protected 접근지정 4. 상속시생성자의실행과정 5. 업캐스팅과 instanceof 연산자 6. 메소드오버라이딩과동적바인딩의이해및활용 7. 추상클래스 8. 인터페이스 상속 (inheritance) 3 객체지향상속 자식이부모유전자를물려받는것과유사한개념

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

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

Microsoft PowerPoint - Lect07.pptx

Microsoft PowerPoint - Lect07.pptx 이강의록은 Power Java 저자의강의록을사용했거나재편집된것입니다. Package 개념 Package 묶는방법사용하기기본 Package Utility Package Generic Class Generic Method Collection ArrayList LinkedList Set Queue Map Collection Class 3 패키지 (package)

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 컬렉션과제네릭개념 2. Vector 활용 3. ArrayList 활용 4. HashMap 활용 5. Iterator 활용 6. 사용자제네릭클래스만들기 컬렉션 (collection) 의개념 3 컬렉션 요소 (element) 라고불리는가변개수의객체들의저장소 객체들의컨테이너라고도불림 요소의개수에따라크기자동조절

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

TEST BANK & SOLUTION

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

More information

슬라이드 1

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

More information

Microsoft PowerPoint - C++ 5 .pptx

Microsoft PowerPoint - C++ 5 .pptx C++ 언어프로그래밍 한밭대학교전자. 제어공학과이승호교수 연산자중복 (operator overloading) 이란? 2 1. 연산자중복이란? 1) 기존에미리정의되어있는연산자 (+, -, /, * 등 ) 들을프로그래머의의도에맞도록새롭게정의하여사용할수있도록지원하는기능 2) 연산자를특정한기능을수행하도록재정의하여사용하면여러가지이점을가질수있음 3) 하나의기능이프로그래머의의도에따라바뀌어동작하는다형성

More information

JAVA PROGRAMMING 실습 02. 표준 입출력

JAVA PROGRAMMING 실습 02. 표준 입출력 # 왜생겼나요..? : 절차지향언어가가진단점을보완하고다음의목적을달성하기위해..! 1. 소프트웨어생산성향상 객체지향소프트웨어를새로만드는경우이미만든개체지향소프트웨어를상속받거나객체를 가져다재사용할수있어부분수정을통해소프트웨어를다시만드는부담줄임. 2. 실세계에대한쉬운모델링 실세계의일은절차나과정보다는일과관련된많은물체들의상호작용으로묘사. 캡슐화 메소드와데이터를클래스내에선언하고구현

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

슬라이드 1

슬라이드 1 9 장. 생성자와가비지컬렉션 학습목표 스택과힙지역변수와인스턴스변수객체생성과생성자객체제거 ( 가비지컬렉션 ) 객체의삶과죽음 그리고그가말했어. 다리에감각이없어! 그리고내가말했지. 조! 정신차려조! 하지만이미너무늦었어. 가비지컬렉터가나타났고그는죽고말았지. 내가만나본가장좋은객체였는데말야 스택과힙 스택 (stack) 메소드호출과지역변수가사는곳 지역변수는스택변수라고도부릅니다.

More information

4장.문장

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

More information

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a 6 장복사생성자 객체의생성과대입객체의값에의한전달복사생성자디폴트복사생성자복사생성자의재정의객체의값에의한반환임시객체 C++ 프로그래밍입문 1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y;

More information

17장 클래스와 메소드

17장 클래스와 메소드 17 장클래스와메소드 박창이 서울시립대학교통계학과 박창이 ( 서울시립대학교통계학과 ) 17 장클래스와메소드 1 / 18 학습내용 객체지향특징들객체출력 init 메소드 str 메소드연산자재정의타입기반의버전다형성 (polymorphism) 박창이 ( 서울시립대학교통계학과 ) 17 장클래스와메소드 2 / 18 객체지향특징들 객체지향프로그래밍의특징 프로그램은객체와함수정의로구성되며대부분의계산은객체에대한연산으로표현됨객체의정의는

More information

Microsoft Word - java18-1-final-answer.doc

Microsoft Word - java18-1-final-answer.doc 기말고사 담당교수 : 단국대학교응용컴퓨터공학박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호 (4자리숫자 ) 를기입하면성적공고시학번대신암호를사용할것임. 1. 다음 sub1 과 sub2

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

Microsoft PowerPoint - java1-lecture5.ppt [호환 모드]

Microsoft PowerPoint - java1-lecture5.ppt [호환 모드] Private Constructor 객체지향개념상속, 추상클래스, 다형성 514760-1 2017 년가을학기 9/25/2017 박경신 Private 생성자 정적멤버만포함하는클래스에서일반적으로사용 클래스가인스턴스화될수없음을분명히하기위해 private constructor를사용 public class Counter { private Counter() { public

More information

슬라이드 1

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

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

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 9 강. 클래스의활용목차 멤버함수의외부정의 this 포인터 friend 선언 static 멤버 임시객체 1 /17 9 강. 클래스의활용멤버함수의외부정의 멤버함수정의구현방법 내부정의 : 클래스선언내에함수정의구현 외부정의 클래스선언 : 함수프로토타입 멤버함수정의 : 클래스선언외부에구현

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

A Tour of Java III

A Tour of Java III A Tour of Java III Sungjoo Ha March 18th, 2016 Sungjoo Ha 1 / 30 Review First principle 문제가생기면침착하게영어로구글에서찾아본다. 타입은가능한값의집합과연산의집합을정의한다. 기본형이아니라면이름표가메모리에달라붙는다. 클래스로사용자정의타입을만든다. 프로그래밍은복잡도관리가중요하다. OOP 는객체가서로메시지를주고받는방식으로프로그램을구성해서복잡도관리를꾀한다.

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 그래픽사용자인터페이스 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 프레임생성 (1) import javax.swing.*; public class FrameTest { public static void main(string[] args) { JFrame f = new JFrame("Frame Test"); JFrame

More information

Microsoft PowerPoint - lec2.ppt

Microsoft PowerPoint - lec2.ppt 2008 학년도 1 학기 상지대학교컴퓨터정보공학부 고광만 강의내용 어휘구조 토큰 주석 자료형기본자료형 참조형배열, 열거형 2 어휘 (lexicon) 어휘구조와자료형 프로그램을구성하는최소기본단위토큰 (token) 이라부름문법적으로의미있는최소의단위컴파일과정의어휘분석단계에서처리 자료형 자료객체가갖는형 구조, 개념, 값, 연산자를정의 3 토큰 (token) 정의문법적으로의미있는최소의단위예,

More information

Microsoft PowerPoint - Chap12-OOP.ppt

Microsoft PowerPoint - Chap12-OOP.ppt 객체지향프로그래밍 (Object Oriented Programming) 12 장강사 강대기 차례 (Agenda) 멤버에대한동적메모리할당 암시적 / 명시적복사생성자 암시적 / 명시적오버로딩대입연산자 생성자에 new 사용하기 static 클래스멤버 객체에위치지정 new 사용하기 객체를지시하는포인터 StringBad 클래스 멤버에포인터사용 str static 멤버

More information

Microsoft PowerPoint - additional08.ppt [호환 모드]

Microsoft PowerPoint - additional08.ppt [호환 모드] 8. 상속과다형성 (polymorphism) 상속된객체와포인터 / 참조자의관계 정적바인딩과동적바인딩 virtual 소멸자 Jong Hyuk Park 상속의조건 public 상속은 is-a 관계가성립되도록하자. 일반화 ParttimeStd 구체화 2 상속의조건 잘못된상속의예 현실세계와완전히동떨어진모델이형성됨 3 상속의조건 HAS-A( 소유 ) 관계에의한상속!

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 제네릭 배효철 th1g@nate.com 1 목차 제네릭 컬렉션 백터 ArrayList HashMap LinkedList Collections 클래스 제네릭만들기 컬렉션과자동박싱 / 언박싱 제네릭의장점 2 제네릭 특정타입만다루지않고, 여러종류의타입으로변신할수있도록클래스나메소드를일반화시키는기법 , , : 타입매개변수 요소타입을일반화한타입 제네릭클래스사례

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 자바의프로그램의기본구조이해 2. 자바의데이터타입이해 3. 자바에서키입력받는방법이해 4. 자바의연산자이해 5. 자바의조건문 (if-else와 switch) 이해 예제 2-1 : Hello, 자바프로그램의기본구조 3 /* * 소스파일 : Hello.java */ public class Hello {? Hello

More information