PowerPoint Presentation

Size: px
Start display at page:

Download "PowerPoint Presentation"

Transcription

1 11 장. 패키지와 주요클래스 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 + " 입니다 "); 1

2 학습목표 패키지의개념과사용방법을학습한다. 자바의기본패키지인 java.lang 패키지의클래스를학습한다. 주요포장 (Wrapper) 클래스를학습한다. String 클래스와 StringBuffer 클래스의메소드사용방법을학습한다. 유틸리티패키지의 Random, Arrays 클래스사용방법을학습한다. 2

3 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 Integer 클래스 Character 클래스 Byte 클래스 Short 클래스 Long 클래스 3

4 목차 section 5 문자열의개요 section 6 String 클래스 문자열의길이 문자열에서의문자추출 문자열비교 문자열탐색 문자열의변환 section 7 StringBuffer 클래스 section 8 유틸리티패키지개요 section 9 Random 클래스 section 10 Arrays 클래스 4

5 1 패키지개요와패키지의사용 패키지 - 비슷한종류의클래스나인터페이스들을하나의집단으로묶어놓은것 5

6 1 패키지개요와패키지의사용 JDK 에서제공되는주요패키지 패키지이름 설명 java.lang 프로그램에서지정하지않아도묵시적으로포함되는패키지로서, 자바프로그램의기본적인기능을제공하는패키지이다. 자바프로그램의최상위클래스인 java.lang.object 클래스가이패키지에포함되어있다. java.util 자바프로그래밍에유용한유틸리티클래스를포함하는패키지이다. java.io java.net java.awt 입출력기능을제공하는패키지로서스트림을다양한형태로처리할수있는기능을제공한다. 네트워킹과관련된기능을제공하는패키지로서 telnet, ftp, http 와같은프로토콜을사용할수있는클래스를제공한다. 그래피컬사용자인터페이스 (GUI) 를구축하기위한다양한컴포넌트를제공하는패키지로서사용자는이패키지를이용하여원하는인터페이스를구축할수있다. java.awt.event AWT 컴포넌트들의이벤트를제어하는패키지이다. java.applet 웹검색기에서수행되는애플릿프로그램을작성하기위해필요한클래스를제공하는패키지 6

7 1 패키지개요와패키지의사용 패키지를사용하는가장일반적인방법 - import 문을사용 import java.util.date;... Date date = new Date();... java.util.date 클래스만을사용 import java.util.*; java.util 패키지의모든클래스를사용... Date date = new Date(); Random random = new Random(); Stack stack = new Stack(); Hashtable hashtable = new Hashtable(); java.util 패키지 7

8 2 java.lang 패키지의개요 java.lang 패키지 - import 문을사용하여포함시키지않아도자동적으로포함되는패키지 8

9 2 java.lang 패키지의개요 java.lang 패키지의클래스 345 page 9

10 3 Object 클래스 java.lang.object 클래스 - 이패키지의최상위클래스이면서모든자바프로그램의최상위클래스 10

11 3 Object 클래스 java.lang.object 클래스의주요메소드 메소드 설명 Ojbect clone() boolean equals (Obje ct object) void finalize() Class getclass() 객체를복제하기위해사용하는메소드 두개의객체가같은지를비교하여같으면 true, 아니면 false 를반환 자바에서는객체가더이상사용되지않으면자동적으로쓰레기수집 (garbage collection) 기능을수행한다. finalize() 메소드는쓰레기수집기능이수행되기전에호출되며객체가점유하고있던자원들을해제하는데사용되는메소드 객체의클래스명을 Class 형의객체로반환 int hashcode() 호출한객체와연관된 hash 코드를얻는다. String tostring() 현재객체의문자열표현을반환한다. void notify() 대기중인스레드중하나의스레드를다시시작시킨다. void notifyall() 대기중인모든스레드를다시시작시킨다. void wait() 스레드의실행을중지하고대기상태로간다. 11

12 4 포장 (Wrapper) 클래스 기본자료형을객체로사용한다는의미 - 기본자료형과관련된클래스를제공한다는의미 포장 (wrapper) 클래스 - 기본자료형객체를지원하기위해, 각각의자료형과관련된클래스들을제공 class ValueandWrapper { public static void main(string args[]) { int num1 = 20; Integer num2 = new Integer(30) Integer num2 = 30; 의형태로사용가능 int total = num1 + num2.intvalue(); Integer 클래스의 intvalue() 메소드로정수값을추출 System.out.println(" 두수의합은 : " + total); Integ Integ 12

13 4 포장 (Wrapper) 클래스 4-1 Integer 클래스 Integer 클래스 - 정수값을포장하는클래스 형식 Integer(int n) Integer(String str) 13

14 4 포장 (Wrapper) 클래스 4-1 Integer 클래스 Integer 클래스의주요메소드 타입 byte bytevalue() double doublevalue() float floatvalue() int intvalue() long longvalue() short shortvalue() String tostring() boolean equals(object IntegerObj) static Integer decode(string str) throws NumberFormatException static int parseint(string str) throws NumberFormatException 설명 현객체의값을 byte 값으로변환하여반환 현객체의값을 double 값으로변환하여반환 현객체의값을 float 값으로변환하여반환 현객체의값을 int 값으로변환하여반환 현객체의값을 long 값으로변환하여반환 현객체의값을 short 값으로변환하여반환 현객체의값을문자열로변환하여반환 현객체와 IntegerObj 로지정된객체의값이같으면 true, 다르면 false 를반환 문자열 str 에해당하는 Integer 객체를반환 문자열 str 에해당하는 int 값을반환 14

15 4 포장 (Wrapper) 클래스 4-1 Integer 클래스 Integer 클래스의주요메소드 타입 static int parseint(string str, int radix) throws NumberFormatException static String tobinarystring(int num) static String tohexstring(int num) static String tooctalstring(int num) static Integer valueof(string str) throws NumberFormatException static Integer valueof(string str, int ra dix) throws NumberFormatException 설명 문자열 str 에해당하는 int 값을 radix 로지정된진법으로반환 num 으로지정된정수값의 2 진법표현을가지는 String 객체를반환 num 으로지정된정수값의 16 진법표현을가지는 String 객체를반환 num 으로지정된정수값의 8 진법표현을가지는 String 객체를반환 문자열 str 에해당하는 Integer 객체를반환 문자열 str 에해당하는 Integer 객체를 radix 로지정된진법으로반환 15

16 4 포장 (Wrapper) 클래스 4-1 Integer 클래스 실습예제 IntegerTest1.java public class IntegerTest1 { public static void main(string args[]) { Integer num1 = new Integer(13); Integer num2 = 25; int hap = num1.intvalue() + num2.intvalue(); System.out.println("num1 이포장하고있는정수는 : " + num1.intvalue()); System.out.println("num2 가포장하고있는정수는 : " + num2.intvalue()); System.out.println(" 두수의합 = " + hap); System.out.println(" 합의 2 진표현 : " + Integer.toBinaryString(hap)); System.out.println(" 합의 8 진표현 : " + Integer.toOctalString(hap)); System.out.println(" 합의 16 진표현 : " + Integer.toHexString(hap)); Integer 객체생성 직접값을지정하여객체생성 두객체가가진값을더한다 클래스메소드호출 16

17 4 포장 (Wrapper) 클래스 4-1 Integer 클래스 실습예제 IntegerTest1.java System.out.println("if(num1 == num2) 는 : " + num1.equals(num2)); Integer num3 = new Integer("444"); System.out.println(" 문자열 '444' 의값은 : " + num3.intvalue()); 17

18 4 포장 (Wrapper) 클래스 4-1 Integer 클래스 18

19 4 포장 (Wrapper) 클래스 4-2 Character 클래스 Character 클래스 - char 형의값을저장 형식 Character(char c) 19

20 4 포장 (Wrapper) 클래스 4-2 Character 클래스 Character 클래스의주요메소드 메소드 설명 static boolean isdefined(char ch) static boolean isdigit(char ch) static boolean isletter(char ch) static boolean isletterordigit(char ch) static boolean islowercase(char ch) static boolean isspace(char ch) static boolean isuppercase(char ch) static char tolowercase(char ch) static char touppercase(char ch) ch가 Unicode이면 true 아니면 false를반환 ch가숫자이면 true 아니면 false를반환 ch가문자이면 true 아니면 false를반환 ch가문자또는숫자이면 true 아니면 false를반환 ch가소문자이면 true 아니면 false를반환 ch가공백문자이면 true 아니면 false를반환 ch가대문자이면 true 아니면 false를반환 ch로지정된문자를소문자로변환하여반환 ch로지정된문자를대문자로변환하여반환 20

21 4 포장 (Wrapper) 클래스 4-2 Character 클래스 실습예제 CharacterTest1.java class CharacterTest1 { public static void main(string args[]) { char a[] = {'a', ' ', '?', 'C', '5', 'A'; for(int i=0; i<a.length; i++) { System.out.println("a[" + i + "] 번째요소 = " + a[i]); if(character.isdigit(a[i])) System.out.println(" 숫자입니다."); if(character.isletter(a[i])) System.out.println(" 문자입니다."); if(character.isspace(a[i])) System.out.println(" 공백문자입니다."); if(character.isuppercase(a[i])) System.out.println(" 대문자입니다."); if(character.islowercase(a[i])) System.out.println(" 소문자입니다."); 문자배열을선언 각문자를클래스메소드로검사 21

22 4 포장 (Wrapper) 클래스 4-2 Character 클래스 실습예제 CharacterTest1.java if(character.isdefned(a[0])) { System.out.println("a[0] 번째요소 = " + a[0]); System.out.println(" 유니코드입니다."); 유니코드인지검사 22

23 4 포장 (Wrapper) 클래스 4-2 Character 클래스 23

24 4 포장 (Wrapper) 클래스 4-3 Byte 클래스 Byte 클래스 - byte 형의값을저장 - MAX_VALUE 와 MIN_VALUE 상수를제공 형식 Byte(byte b) Byte(String s) throws NumberFormatException 24

25 4 포장 (Wrapper) 클래스 4-3 Byte 클래스 Byte 클래스의주요메소드 메소드 설명 byte bytevalue() 현객체의값을 byte 값으로변환하여반환 double doublevalue() 현객체의값을 double 값으로변환하여반환 float floatvalue() 현객체의값을 float 값으로변환하여반환 int intvalue() 현객체의값을 int 값으로변환하여반환 long longvalue() 현객체의값을 long 값으로변환하여반환 short shortvalue() 현객체의값을 short 값으로변환하여반환 String tostring() boolean equals(object BytesObj) static Byte decode(string str) throws NumberFormatException static byte parsebyte(string str) throws NumberFormatException static byte parsebyte(string str, int radix) throws NumberFormatException 현객체의값을문자열로변환하여반환 현객체가가지고있는값과 BytesObj 로지정된객체가가지고있는값이같으면 true, 다르면 false 를반환 str 로지정된문자열에해당하는 Byte 객체를반환 str 로지정된문자열에해당하는 byte 값을반환 str 로지정된문자열에해당하는 byte 값을 radix 로지정된진법으로반환 25

26 4 포장 (Wrapper) 클래스 4-3 Byte 클래스 실습예제 ByteTest.java public class ByteTest { public static void main(string args[]) { Byte b1 = new Byte("126"); byte b2 = Byte.parseByte("1"); byte btotal1 = (byte)(b1.bytevalue() + b2); System.out.println("byte 덧셈의결과 1 : " + btotal1); Byte b3 = 1; byte btotal2 = (byte)(b3.bytevalue() + btotal1); "126" 문자열로 Byte 객체생성 System.out.println("byte 덧셈의결과 2 : " + btotal2); byte 형변수초기화 ( 클래스메소드이용 ) 직접숫자를지정하여 Byte 객체생성 정수 (int) 연산수행후 (byte) 형변환 26

27 4 포장 (Wrapper) 클래스 4-3 Byte 클래스 27

28 4 포장 (Wrapper) 클래스 4-4 Short 클래스 Short 클래스 - short 형의값을저장 - MAX_VALUE 와 MIN_VALUE 상수를제공 형식 Short(short s) Short(String str) throws NumberFormatException 28

29 4 포장 (Wrapper) 클래스 4-4 Short 클래스 Short 클래스의주요메소드 메소드 설명 byte bytevalue() 현객체의값을 byte 값으로변환하여반환 double doublevalue() 현객체의값을 double 값으로변환하여반환 short longvalue() 현객체의값을 long 값으로변환하여반환 float floatvalue() 현객체의값을 float 값으로변환하여반환 int intvalue() 현객체의값을 int 값으로변환하여반환 short shortvalue() 현객체의값을 short 값으로변환하여반환 String tostring() boolean equals(object ShortObj) static Short decode(string str) throws NumberFormatException static short parseshort(string str) throws NumberFormatException static short parseshort(string str, int radix) throws NumberFormatException 현객체의값을문자열로변환하여반환 현객체가가지고있는값과 ShortObj 로지정된객체가가지고있는값이같으면 true, 다르면 false 를반환 str 로지정된문자열에해당하는 Short 객체를반환 str 로지정된문자열에해당하는 short 값을반환 str 로지정된문자열에해당하는 short 값을 radix 로지정된진법으로반환 29

30 4 포장 (Wrapper) 클래스 4-4 Short 클래스 실습예제 ShortTest.java public class ShortTest { public static void main(string args[]) { Short s1 = new Short((short)30); short s2 = Short.parseShort("20"); short stotal = (short)(s1.intvalue() + s2); System.out.println("short 덧셈의결과 : " + stotal); 숫자를 short 형으로형변환하여객체생성 30

31 4 포장 (Wrapper) 클래스 4-5 Long 클래스 Long 클래스 - long 형의값을저장 - MAX_VALUE 와 MIN_VALUE 상수를제공 형식 Long(long l) Long(String str) throws NumberFormatException 31

32 4 포장 (Wrapper) 클래스 4-5 Long 클래스 Long 클래스의주요메소드 메소드 설명 byte bytevalue() 현객체의값을 byte 값으로변환하여반환 double doublevalue() 현객체의값을 double 값으로변환하여반환 float floatvalue() 현객체의값을 float 값으로변환하여반환 short shortvalue() 현객체의값을 short 값으로변환하여반환 int intvalue() 현객체의값을 int 값으로변환하여반환 long longvalue() 현객체의값을 long 값으로변환하여반환 String tostring() boolean equals(object LongObj) static long parselong(string str) throws NumberFormatException static long parselong(string str, int radix) throws NumberFormatException static String tobinarystring(long num) 현객체의값을문자열로반환 현객체가가지고있는값과 LongObj 로지정된객체가가지고있는값이같으면 true, 다르면 false 를반환 str 로지정된문자열에해당하는 long 값을반환 str 로지정된문자열에해당하는 long 값을 radix 로지정된진법으로반환 num 의 2 진표현을문자열로반환 32

33 4 포장 (Wrapper) 클래스 4-5 Long 클래스 Long 클래스의주요메소드 메소드 static String tohexstring(long num) static String tooctalstring(long num) static Long valueof(string str) throws NumberFormatException 설명 num의 16진표현을문자열로반환 num의 8진표현을문자열로반환 str로지정된값을가지는 Long 객체를반환 33

34 4 포장 (Wrapper) 클래스 4-5 Long 클래스 실습예제 LongTest.java public class LongTest { public static void main(string args[]) { Long a = new Long(Long.MAX_VALUE); System.out.println ("Long 의최댓값 (10 진법 ) : " + a.longvalue()); System.out.println ("Long 의최댓값 (2 진법 ) : " + Long.toBinaryString(a.longValue())); System.out.println ("Long 의최댓값 (8 진법 ) : " + Long.toOctalString(a.longValue())); System.out.println ("Long 의최댓값 (16 진법 ) : " + Long.toHexString(a.longValue())); System.out.println ("=========================================="); a = new Long(Long.MIN_VALUE); System.out.println ("Long 의최솟값 (10 진법 ) : " + a ); long 최댓값출력 long 최솟값출력 Long 최댓값객체생성 Long 최솟값객체생성 34

35 4 포장 (Wrapper) 클래스 4-5 Long 클래스 실습예제 LongTest.java System.out.println ("Long 의최솟값 (2 진법 ) : " + Long.toBinaryString(a)); System.out.println ("Long 의최솟값 (8 진법 ) : " + Long.toOctalString(a)); System.out.println ("Long 의최솟값 (16 진법 ) : " + Long.toHexString(a)); 35

36 4 포장 (Wrapper) 클래스 4-5 Long 클래스 36

37 5 문자열의개요 문자열 (String) - 자바프로그램에서많이사용되는요소 - 자바는문자열을객체로취급 - 상수문자열을사용할때 : String 클래스 - 계속변하는문자열을사용할때 : StringBuffer 클래스 37

38 6 String 클래스 String 클래스 - 변하지않는문자열 - 상수문자열을위해사용 - 문자열을생성하고조작할수있도록다양한생성자와메소드를제공 형식 String() String(char chars[]) String(char chars[], int startindex, int numchars) String(String strobj) String(byte asciichars[], byte highorderbyte) String(byte asciichars[], byte highorderbyte, int startindex, int numchars) String(byte asciichars[]) String(byte asciichars[], int startindex, int numchars) 38

39 6 String 클래스 String 클래스의주요메소드 메소드 설명 int length() 문자열의길이를반환 char charat(int I) void getchars(int sourcestart, int sourceend, char target[], int targetstart) byte[] getbytes() boolean equals(object str) boolean equalsignorecase(string str) boolean startswith(string str) i 번째문자를반환 문자열의일부를문자배열 (target[]) 로작성 현재의문자열을바이트배열로반환 현재의문자열과 str로지정된문자열이같으면 true, 다르면 false를반환현재의문자열과 str로지정된문자열이같으면 true, 다르면 false를반환. 단, 비교시대소문자를무시 현재의문자열이 str 로시작하면 true, 아니면 false 를반환 boolean endswith(string str) int compareto(string str) int indexof(char ch) int indexof(string str) 현재의문자열이 str 로끝나면 true, 아니면 false 를반환 두개의문자열을비교하여결과로양수, 음수, 0의값을반환현재의객체가가지고있는문자열내에서 ch로지정된문자의첫번째인덱스를반환 문자열 str 의첫번째인덱스를반환 39

40 6 String 클래스 String 클래스의주요메소드 메소드 int indexof(int ch, int startindex) int indexof(string str, int startindex) String intern() int lastindexof(char ch) int lastindexof(string str) int lastindexof(int ch, int startindex) int lastindexof(string str, int startindex) String substring(int startindex) String substring(int startindex, int endindex) String concat(string str) String replace(char original, char replacement) 설명 인덱스 startindex 이후의문자 ch의첫번째인덱스를반환인덱스 startindex 이후의문자열 str의첫번째인덱스를반환문자열의 canonical 문자열을반환문자 ch의마지막인덱스를반환문자열 str의마지막인덱스를반환인덱스 startindex 이전의문자 ch의마지막인덱스를반환인덱스 startindex 이전의문자열 str의마지막인덱스를반환 startindex로부터시작하는부분문자열을반환 startindex와 endindex 사이의부분문자열을반환현재의문자열에 str로지정된문자열을결합 original로지정된문자를 replacement로지정된문자로대치 40

41 6 String 클래스 String 클래스의주요메소드 메소드 설명 String trim() static String valueof(double num) static String valueof(long num) static String valueof(object obj) static String valueof(char chars[]) static String valueof(char chars[], int startindex, int numc hars) String tolowercase() String touppercase() 문자열의앞뒤공백 (whitespace) 을제거 num을문자열로변환하여반환 num을문자열로변환하여반환객체가가지고있는데이터를문자열로변환하여반환문자배열을문자열로변환하여반환문자배열의일부를문자열로변환하여반환문자열을모두소문자로변환하여반환문자열을모두대문자로변환하여반환 41

42 6 String 클래스 실습예제 StringTest1.java public class StringTest1 { public static void main(string args[]) { char a[] = { 'C','o','m','p','u','t','e','r' ; String s1 = new String(a); String s2 = new String(a,3,2); String s3 = new String(" 배우기쉬운자바 "); String s4 = "canonical 문자열 "; System.out.println(" 문자열 s1 : " + s1); System.out.println(" 문자열 s1 의길이 : " + s1.length()); System.out.println(" 문자열 s2 : " + s2); System.out.println(" 문자열 s3 : " + s3); System.out.println(" 문자열 s4 : " + s4); 배열을이용하여객체생성 배열의특정부분을이용하여객체생성 문자열을지정하여객체생성 문자열의길이출력 42

43 6 String 클래스 43

44 6 String 클래스 canonical 문자열 - 자바는편리한문자열의사용을위해단축 (shorthand) 초기화를허용 - 단축초기화과정을거쳐생성된문자열 String name = "kim" name = "park" 44

45 6 String 클래스 실습예제 StringTest2.java public class StringTest2 { public static void main(string args[]) { String s1 = "Java Korea"; String s2 = new String("Java Korea"); String s3 = s2.intern(); String s4 = "Java Korea"; String s5 = new String("Java Korea"); canonical 문자열객체생성 일반문자열객체생성 intern() 메소드를이용하여 canonical 문자열객체생성 System.out.println("s1 과 s2 가같은가? : " + (s1 == s2)); System.out.println("s2 와 s3 가같은가? : " + (s2 == s3)); System.out.println("s1 과 s3 가같은가? : " + (s1 == s3)); System.out.println("s1 과 s4 가같은가? : " + (s1 == s4)); System.out.println("s2 와 s5 가같은가? : " + (s2 == s5)); System.out.println("s1 : " + s1); System.out.println("s2 : " + s2); System.out.println("s3 : " + s3); System.out.println("s4 : " + s4); System.out.println("s5 : " + s5); 45

46 6 String 클래스 46

47 6 String 클래스 6-1 문자열의길이 문자열길이메소드 형식 int length() char chars[] = {'K', 'o', 'r', 'e', 'a'; String s = new String(chars); System.out.println(s.length()); 47

48 6 String 클래스 6-2 문자열에서의문자추출 문자열추출메소드 - charat() 메소드 : 문자열의특정위치에있는문자를반환 - getchars() 메소드 : 문자열의일부를문자배열로제공 형식 char charat(int i) void getchars(int sourcestart, int sourceend, char target[], int targetstart) 48

49 6 String 클래스 6-2 문자열에서의문자추출 시습예제 StringExtract.java public class StringExtract { public static void main(string args[]) { String a1 = "WorldCup Korea"; System.out.println(" 추출된문자 : " + a1.charat(2)); char buff[] = new char[3]; a1.getchars(5,8,buff,0); System.out.println(buff); 문자열의 5-7 번문자를출력 문자열의 2 번째 (0 부터시작 ) 문자를출력 49

50 6 String 클래스 6-2 문자열에서의문자추출 50

51 6 String 클래스 6-3 문자열비교 문자열비교메소드 - equals() 메소드 : 현재의문자열과 str로지정된문자열이같으면 true, 다르면 false를반환 - equalsignorecase() 메소드 : equals() 메소드와같으나대소문자를구분하지않고비교 - compareto() 메소드 : 두개의문자열을비교하여문자열이다른문자열보다작으면음수값을, 같으면 0 값을, 크면양수값을반환 - startswith(), endswith() 메소드 : str로지정된문자열로시작하거나끝나면 true를그렇지않으면 false를반환 형식 boolean equals(object str) boolean equalsignorecase(string str) int compareto(string str) boolean startswith(string str) boolean endswith(string str) 51

52 6 String 클래스 6-3 문자열비교 실습예제 EqualsTest.java class EqualsTest { public static void main(string args[]) { String s1 = " 알기쉽다 " ; String s2 = "Apple"; String s3 = "APPLE"; String s4 = new String(" 알기쉽다 "); System.out.println ("s1 과 s2 가동일한문자열? : " + s1.equals(s2)); System.out.println ("s2 와 s3 가동일한문자열?( 대소문자무시 ) : " + s2.equalsignorecase(s3)); if (s1 == s4) else System.out.println 객체변수가가진값 ( 주소 ) 비교 ("s1 과 s4 를 \"==\" 연산자로비교한결과는같다 "); equals() 메소드로비교 대소문자무시비교 52

53 6 String 클래스 6-3 문자열비교 실습예제 EqualsTest.java System.out.println ("s1 과 s4 를 \"==\" 연산자로비교한결과는같지않다 "); if (s1.equals(s4)) else System.out.println ("s1 과 s4 를 \"equals()\" 메소드로비교한결과는같다 "); System.out.println ("s1 과 s4 를 \"equals()\" 메소드로비교한결과는같지않다 "); System.out.println ("s1 문자열은 \" 알기 \" 로시작하는가? " + s1.startswith(" 알기 ")); System.out.println 객체변수가지정하는문자열비교 ("s1 문자열은 \"ple\" 로끝나는가? " + s2.endswith("ple")); 문자열시작과끝을비교 53

54 6 String 클래스 6-3 문자열비교 54

55 6 String 클래스 6-3 문자열비교 실습예제 CompareTest.java public class CompareTest { static String array1[] = {"IMF", " 제주도 ", " 자바도사 ", " 한글나라 ", "Computer", " 모카 ", "JAVA", " 인터넷탐색 ", " 초롱초롱 ", "come", " 바람 ", " 스크립터 ", " 군고구마 ", " 도서 ", "their", "country" ; public static void main(string args[]) { System.out.println("======= 정렬전데이터 =========="); for(int k = 0; k < array1.length; k++) System.out.print(array1[k] + " "); System.out.println(); System.out.println("======= 정렬후데이터 =========="); for(int i = 0; i < array1.length; i++) { for(int j = i + 1; j < array1.length; j++) { if(array1[i].compareto(array1[j]) > 0) { String t = array1[i]; array1[i] = array1[j]; array1[j] = t; 두개의문자열교환 정렬전데이터를출력 문자열의배열을클래스객체변수로선언 두개의문자열비교 55

56 6 String 클래스 6-3 문자열비교 실습예제 CompareTest.java System.out.print(array1[i] + " "); 56

57 6 String 클래스 6-3 문자열비교 57

58 6 String 클래스 6-4 문자열탐색 문자열탐색메소드 - indexof() 메소드 : 문자열에서특정문자나문자열을탐색하여위치를반환하는메소드 - lastindexof() 메소드 : 문자열에서특정문자나문자열을마지막위치부터거꾸로탐색하여위치를반환하는메소드 형식 int indexof(string str) int indexof(int ch, int startindex) int indexof(string str, int startindex) int lastindexof(string str) int lastindexof(int ch, int startindex) int lastindexof(string str, int startindex) 58

59 6 String 클래스 6-4 문자열탐색 실습예제 StringIndexTest.java public class StringIndexTest { public static void main(string args[]) { String s = " JAVA java"; System.out.println(s); System.out.println (" 문자열의길이 : " + s.length()); System.out.println ("indexof(j) = " + s.indexof('j')); System.out.println ("lastindexof(9) = " + s.lastindexof('9')); System.out.println ("indexof(5, 5) = " + s.indexof('5', 5)); J 문자의처음위치 9 문자의마지막위치 5 번째이후 5 문자의처음위치 59

60 6 String 클래스 6-4 문자열탐색 실습예제 StringIndexTest.java System.out.println ("lastindexof(5, 18) = " + s.lastindexof('5', 17)); System.out.println ("indexof(java, 10) = " + s.indexof("java", 10)); System.out.println ("lastindexof(java, 40) = " + s.lastindexof("java", 23)); 17 번째이전 5 문자의위치 10 번째이후 java 문자열의위치 23 번째이전 Java 문자열의위치 60

61 6 String 클래스 6-4 문자열탐색 61

62 6 String 클래스 6-5 문자열의변환 문자열변환메소드 형식 String substring(int startindex, int endindex) String concat(string constr) String replace(char original, char replacement) String trim() 형변환메소드 형식 static String valueof(double num) static String valueof(long num) static String valueof(object obj) static String valueof(char chars[]) static String valueof(char chars[], int startindex, int numchars) 62

63 6 String 클래스 6-5 문자열의변환 대소문자변환메소드 형식 String tolowercase() String touppercase() 63

64 6 String 클래스 6-5 문자열의변환 실습예제 SubStringTest.java public class SubStringTest { public static void main(string args[]) { String str = " 알기쉽게해설한자바 "; System.out.println(" 인덱스 5 부터 8 이전까지의문자열 : " + str.substring(5,8)); System.out.println(str.concat(" 와예제프로그램 ")); System.out.println(str.replace(' 한 ',' 된 ')); str = " " + str + " "; System.out.println(" 공백추가 str 의길이 : " + str.length()); str = str.trim(); 문자열양쪽의공백제거 특정문자를치환 System.out.println(" 공백제거 str 의길이 : " + str.length()); 문자열연결 5 부터 8 이전까지의문자열 64

65 6 String 클래스 6-5 문자열의변환 프로그램설명 - 04, 05 : 위치를지정하여문자열의부분문자열을구하는메소드이다 : 두개의문자열을연결하는메소드이다 : 문자열에서특정문자를다른문자로치환하는메소드이다 : 문자열양쪽에있는공백문자들을제거하는메소드이다. 65

66 6 String 클래스 6-5 문자열의변환 실습예제 ConvertStringTest.java public class ConvertStringTest { public static void main(string args[]) { int a = 2002 ; char b[] = {'W','o','r','l','d','c','u','p'; System.out.println(String.valueOf(a) + " " + String.valueOf(b) + " in Korea"); String s1 = String.valueOf(b); System.out.println(String.valueOf(a) + " " + s1.touppercase() + " in Korea"); System.out.println(String.valueOf(a) + " " + String.valueOf(b).toUpperCase() + " in Korea"); 정수 2002 를문자열로변환 문자배열을문자열로변환 문자열을대문자로변환 연결메소드사용 66

67 6 String 클래스 6-5 문자열의변환 67

68 7 StringBuffer 클래스 StringBuffer 클래스생성자 - StringBuffer() 생성자 : 묵시적으로 16개의문자를저장할수있는객체를생성 - StringBuffer(int size) 생성자 : size로지정된문자를저장할수있는객체를생성 - StringBuffer(String str) 생성자 : str로지정된문자열과추가로 16개의문자를더저장할수있는객체를생성 형식 StringBuffer() StringBuffer(int size) StringBuffer(String str) 68

69 7 StringBuffer 클래스 StringBuffer 클래스의주요메소드 메소드 StringBuffer append(boolean b) StringBuffer append(char ch) StringBuffer append(double d) StringBuffer append(float f) StringBuffer append(int i) StringBuffer append(long l) StringBuffer append(object obj) StringBuffer append(object obj) StringBuffer append(string str) int capacity() char charat(int i) StringBuffer delete(int start, int end) 설명 b를현재의문자열끝에첨부 ch를현재의문자열끝에첨부 d를현재의문자열끝에첨부 f를현재의문자열끝에첨부 i를현재의문자열끝에첨부 l을현재의문자열끝에첨부 obj가가진문자열을현재의문자열끝에첨부 obj가가진문자열을현재의문자열끝에첨부 str을현재의문자열끝에첨부현재의문자열버퍼의크기를반환번째인덱스에해당하는문자를반환문자열의 start에서 end까지를삭제 69

70 7 StringBuffer 클래스 StringBuffer 클래스의주요메소드 메소드 StringBuffer insert(int i, boolean b) StringBuffer insert(int i, char ch) StringBuffer insert(int i, int j) StringBuffer insert(int i, long l) StringBuffer insert(int i, Object obj) StringBuffer insert(int i, String str) int length() StringBuffer reverse() void setcharat(int i, char ch) void setlength(int len) String tostring() String substring(int s, int e) 설명 i번째인덱스전에 b를삽입 i번째인덱스전에 ch를삽입 i번째인덱스전에 j를삽입 i번째인덱스전에 l을삽입 i번째인덱스전에 obj를삽입 i번째인덱스전에 str을삽입문자열버퍼에있는문자의개수를반환문자열을역순의문자열로변환하여반환 i번째문자를 ch로설정버퍼의크기를 len 크기로설정현재의문자열을 String 객체로반환문자열의 s부터 e까지를 string 객체로반환 70

71 7 StringBuffer 클래스 실습예제 StringBufferTest1.java public class StringBufferTest1 { public static void main(string args[]) { StringBuffer str1 = new StringBuffer("Hello JAVA"); StringBuffer str2 = new StringBuffer(" 안녕하세요자바 "); System.out.println(" 문자열 => " + str1); System.out.println(" 문자열길이 => " + str1.length()); System.out.println(" 버퍼를포함한길이 => " + str1.capacity()); System.out.println(" 문자열 => " + str2); System.out.println(" 문자열길이 => " + str2.length()); System.out.println(" 버퍼를포함한길이 => " + str2.capacity()); 버퍼를포함한용량 71

72 7 StringBuffer 클래스 72

73 7 StringBuffer 클래스 실습예제 StringBufferTest2.java public class StringBufferTest2 { public static void main(string args[]) { StringBuffer str1 = new StringBuffer(" 안녕자바 "); System.out.println(" 버퍼에들어있는내용 => " + str1); System.out.println(" 문자열끼워넣기 => " + str1.insert(3,"power ")); System.out.println(" 버퍼의 5 번째문자 => " + str1.charat(4)); str1.setcharat(0, ' 정 '); System.out.println("0 번째값을 ' 정 ' 으로변경 => " + str1); str1.setlength(8); System.out.println(" 버퍼의새로운값 => " + str1); System.out.println(" 문자열의역순출력하기 => " + str1.reverse()); 3 번째위치에문자열삽입 4 번째위치에문자열삽입 0 번째위치의문자를 정 으로치환 문자열의길이를 8 로조정 문자열을역순으로출력 73

74 7 StringBuffer 클래스 74

75 8 유틸리티패키지개요 java.util 패키지의주요클래스 384 page 75

76 8 유틸리티패키지개요 java.util 패키지의주요클래스 384 page 76

77 9 Random 클래스 Random 클래스 - 난수발생기능을제공 - double, float, int, long 등다양한형태 Random 클래스생성자 - Random() 생성자 : 현재의시간을초깃값으로하는난수발생기를생성 - Random (long seed) 생성자 : seed 값을초깃값으로하는난수발생기를생성 형식 Random() Random(long seed) 77

78 9 Random 클래스 Random 클래스의주요메소드 메소드 설명 void nextbytes(byte buffer[]) buffer 를난수로채운다. float nextfloat() int nextint() long getlong() double nextdouble() double nextgaussian() void setseed(long newseed) float형의난수를반환 int형의난수를반환 long형의난수를반환 double형의난수를반환 Gaussian형의난수를 double 값으로반환난수발생기의 seed 값을 newseed 값으로설정 78

79 9 Random 클래스 실습예제 RandomTest.java import java.util.*; public class RandomTest { public static void main(string args[]) { Random rangen = new Random(); for(int i = 1 ; i <= 5 ; i++) { foat a = rangen.nextfloat(); System.out.print("Float 형난수 : " + a); int b = rangen.nextint(); java.util 패키지를포함 System.out.println(" Int 형난수 : " + b); Random 객체생성 실수형의난수생성 정수형의난수생성 79

80 9 Random 클래스 80

81 10 Arrays 클래스 Arrays 클래스의객체 - 자바에서배열은객체로취급하며, 사용하는모든배열 Arrays 클래스의주요메소드 메소드 static List aslist(object[] a) static int binarysearch(int[] a, int key) static boolean equals(int[] a, int[] b) static void fill(int[] a, int value) static void fill(int[] a, int from, int to, int value) static void sort(int[] a) static void sort(int[] a, int from, int to) static String tostring(int[] a) 설명 배열 a 를 List 형의객체로반환 배열 a에서 key로지정된값을찾아반환. boolean을제외한 7가지기본자료형과 Object형도사용가능. 이메소드는배열요소들이정렬된후에사용해야한다. 배열 a와 b가같은지를비교하여결과를반환. 8개의기본자료형과 Object형도사용가능배열 a의모든요소를 value 값으로설정한다. 8개의기본자료형과 Object형도사용가능배열 a의 from부터 to까지를 value 값으로설정한다. 8개의기본자료형과 Object형도사용가능배열 a의요소들을정렬. boolean을제외한 7가지기본자료형과 Object형도사용가능배열 a의 from부터 to까지를정렬. boolean을제외한 7가지기본자료형과 Object형도사용가능배열 a의요소들을문자열로반환한다. 이메소드는모든자료형에적용가능 81

82 10 Arrays 클래스 실습예제 ArraysTest1.java import java.util.*; public class ArraysTest1 { public static void main(string[] args) { int[] int1 = {0,1,2,3,4,5,6,7,8,9; System.out.println(" 초기배열 : " + Arrays.toString(int1)); Arrays.fll(int1, 3, 5, 33); System.out.println("fll() 수행후 : " + Arrays.toString(int1)); Arrays.sort(int1); System.out.println("sort() 수행후 : " + Arrays.toString(int1)); System.out.println("33 은배열의 " + Arrays.binarySearch(int1,33) + " 번째요소 "); int[] int2 = {5,4,3,2,1; 배열요소정렬 System.out.println(" 두번째배열 : " + Arrays.toString(int2)); System.out.println(" 두개의배열이같은가? " + Arrays.equals(int1, int2)); 배열의특정위치값을치환 배열요소 2 진탐색 배열이같은지검사 배열의요소를문자열로출력 82

83 10 Arrays 클래스 83

84 10 Arrays 클래스 실습예제 ArraysTest2.java import java.util.arrays; public class ArraysTest2 { static String array1[] = {"IMF", " 제주도 ", " 자바도사 ", " 한글나라 ", "Computer", " 모카 ", "JAVA", " 인터넷탐색 ", " 초롱초롱 ", "come", " 바람 ", " 스크립터 ", " 군고구마 ", " 도서 ", "their", "country" ; public static void main(string args[]) { System.out.println("======= 정렬전데이터 =========="); System.out.println(Arrays.toString(array1)); Arrays.sort(array1); 배열의요소를정렬 System.out.println("======= 정렬후데이터 =========="); System.out.println(Arrays.toString(array1)); 84

85 10 Arrays 클래스 85

86 학습정리 패키지개요와패키지사용 1 JDK 는클래스들의특성에따라클래스들을패키지로구분하여제공하고있다. 2 import 문을사용하여원하는패키지를포함하여클래스를작성할수있다. java.lang 패키지의개요 1 자바의기본패키지로서 import 문을사용하여포함시키지않아도자동으로포함되 는패키지이다. Object 클래스 1 모든자바클래스의최상위클래스이다. 2 Object 클래스는 extends로지정하지않아도상속되는클래스이다. 3 Object 클래스에서선언된메소드는모든자바프로그램에서사용이가능하다. 86

87 학습정리 포장 (Wrapper) 클래스 1 자바에서사용되는 8개의기본자료형에대해포장클래스를제공한다. 2 포장클래스를사용함으로써클래스에서제공되는다양한기능의메소드를쉽게사용할수있다. 문자열의개요 1 자바는문자열을위해 String 클래스와 StringBuffer 클래스를제공하고있다. 2 한번생성된다음에변하지않는문자열, 즉상수문자열을사용할때는 String 클래스를이용하고, 프로그램에서계속변하는문자열을사용할때는 StringBuffer 클래스를이용한다. java.util 패키지 1 자바는다양한기능을가진클래스들을 java.util 패키지로제공하고있다. 2 Random 클래스는난수를발생시키는클래스로서, 다양한형태의난수를생성할수있다. 3 Arrays 클래스는배열을나타내는클래스로서, 다양하고편리한메소드를제공하고있다. 87

88 88

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

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

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

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

(Microsoft PowerPoint - CLXBUOPUGXNK.ppt [\310\243\310\257 \270\360\265\345]) 자바패기지 학습목표 자바패키지의개념을이해한다. 패키지의종류, 사용및선언방법을이해한다. 자바패키지압축 기능이비슷한라이브러리클래스나인터페이스들을하나의집단으로묶어놓은것 작성자 자바프로그래밍언어혹은사용자 패키지의예 String 클래스, 입출력에관한클래스및인터페이스, 네트워크에관련된클래스등등 패키지에포함된클래스 기본패키지디렉토리 : C:\jdk1.5.0\jre\lib

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

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

More information

슬라이드 1

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

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

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

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

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

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

쉽게 풀어쓴 C 프로그래밍

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

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

<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

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 자료구조자바세미나 Week1 00 Contents 목차 01 Introduction 02 JAVA? 03 Basic Grammar 04 Array 05 String 06 Class & Method 07 Practice 01 Introduction 자료구조자바세미나기본소개 일시장소 IDE 대상 매주수요일저녁 6 시 (2019.03.20 ~ 2019.04.10)

More information

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

Microsoft PowerPoint - lec06_08.ppt [호환 모드] JAVA 프로그래밍 6. 배열과배열리스트 한동일 학습목표 To become familiar with using arrays and array lists To learn about wrapper classes, auto-boxing and the generalized for loop To study common array algorithms To learn how

More information

<4A DC1DFBFE4C5ACB7A1BDBA2E687770>

<4A DC1DFBFE4C5ACB7A1BDBA2E687770> JAVA 중요클래스 자바에서는프로그래밍개발에필요한여러패키지를지원한다. 패키지는 c 언어의라이브러리(include) 와비슷한개념이면서패키지에대한설명은 4 장에서설명하였으니참고할것. 사용자는자바에서지원하는여러패키지를상속받아어플리케이션이나애플릿코딩시자성하며또한자신이직접만든클래스를모아패키지를정의하여쓰기도한다. 자바에서는여러패키지중가장중요하고널리사용되는 java.lang,

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

쉽게 풀어쓴 C 프로그래밍

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

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

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

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

PowerPoint 프레젠테이션

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

More information

쉽게

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

More information

JAVA PROGRAMMING 실습 09. 예외처리

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

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

Microsoft PowerPoint - ch07 - 포인터 pm0415

Microsoft PowerPoint - ch07 - 포인터 pm0415 2015-1 프로그래밍언어 7. 포인터 (Pointer), 동적메모리할당 2015 년 4 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) Outline 포인터 (pointer) 란? 간접참조연산자

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

제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

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

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 System Software Experiment 1 Lecture 5 - Array Spring 2019 Hwansoo Han (hhan@skku.edu) Advanced Research on Compilers and Systems, ARCS LAB Sungkyunkwan University http://arcs.skku.edu/ 1 배열 (Array) 동일한타입의데이터가여러개저장되어있는저장장소

More information

Microsoft PowerPoint - C++ 5 .pptx

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

More information

TEST BANK & SOLUTION

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

More information

학습목차 2.1 다차원배열이란 차원배열의주소와값의참조

학습목차 2.1 다차원배열이란 차원배열의주소와값의참조 - Part2- 제 2 장다차원배열이란무엇인가 학습목차 2.1 다차원배열이란 2. 2 2 차원배열의주소와값의참조 2.1 다차원배열이란 2.1 다차원배열이란 (1/14) 다차원배열 : 2 차원이상의배열을의미 1 차원배열과다차원배열의비교 1 차원배열 int array [12] 행 2 차원배열 int array [4][3] 행 열 3 차원배열 int array [2][2][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 오류메시지를분석한다. 오류메시지에서많은내용을알수있다. 2 디버깅 디버거를사용하면프로그램에서쉽게오류를감지하고진단할수있다. 디버거는중단점을설정하여서프로그램의실행을제어할수있으며문장 단위로실행하거나변수의값을살펴볼수있다. 3 이클립스에서디버깅 4 이클립스에서디버깅 5 이클립스의디버깅명령어 6 예외처리

More information

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770>

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770> 연습문제해답 5 4 3 2 1 0 함수의반환값 =15 5 4 3 2 1 0 함수의반환값 =95 10 7 4 1-2 함수의반환값 =3 1 2 3 4 5 연습문제해답 1. C 언어에서의배열에대하여다음중맞는것은? (1) 3차원이상의배열은불가능하다. (2) 배열의이름은포인터와같은역할을한다. (3) 배열의인덱스는 1에서부터시작한다. (4) 선언한다음, 실행도중에배열의크기를변경하는것이가능하다.

More information

JAVA PROGRAMMING 실습 02. 표준 입출력

JAVA PROGRAMMING 실습 02. 표준 입출력 # 메소드의구조자주반복하여사용하는내용에대해특정이름으로정의한묶음 반환형메소드이름 ( 매개변수 ) { 실행문장 1; : 실행문장 N; } 메소드의종류 Call By Name : 메서드의이름에의해호출되는메서드로특정매개변수없이실행 Call By Value : 메서드를이름으로호출할때특정매개변수를전달하여그값을기초로실행하는메서드 Call By Reference : 메서드호출시매개변수로사용되는값이특정위치를참조하는

More information

쉽게 풀어쓴 C 프로그래밍

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

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

Java ~ Java program: main() class class» public static void main(string args[])» First.java (main class ) /* The first simple program */ public class

Java ~ Java program: main() class class» public static void main(string args[])» First.java (main class ) /* The first simple program */ public class Linux JAVA 1. http://java.sun.com/j2se/1.4.2/download.html J2SE 1.4.2 SDK 2. Linux RPM ( 9 ) 3. sh j2sdk-1_4_2_07-linux-i586-rpm.bin 4. rpm Uvh j2sdk-1_4_2_07-linux-i586-rpm 5. PATH JAVA 1. vi.bash_profile

More information

Microsoft PowerPoint - chap06-1Array.ppt

Microsoft PowerPoint - chap06-1Array.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-1 참고자료 배열 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 배열의선언과사용 같은형태의자료형이많이필요할때배열을사용하면효과적이다. 배열의선언 배열의사용 배열과반복문 배열의초기화 유연성있게배열다루기 한빛미디어

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 10 포인터 01 포인터의기본 02 인자전달방법 03 포인터와배열 04 포인터와문자열 변수의주소를저장하는포인터에대해알아본다. 함수의인자를값과주소로전달하는방법을알아본다. 포인터와배열의관계를알아본다. 포인터와문자열의관계를알아본다. 1.1 포인터선언 포인터선언방법 자료형 * 변수명 ; int * ptr; * 연산자가하나이면 1 차원포인터 1 차원포인터는일반변수의주소를값으로가짐

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

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

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

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

No Slide Title

No Slide Title 객체의이용 이충기 명지대학교컴퓨터공학과 들어가며 Q: 어떤집의설계도에따라집을서울, 용인과강릉에짓는다면이집들을어떻게구별할까? A: 2 객체와참조 실세계의한대상을모델한클래스를이용하기위해서는객체를생성해야한다. 한클래스로부터여러개의객체들을생성할수있다. 이객체들을서로구별하기위해객체를가리키는참조형변수를사용한다. 참조는가리키는객체의주소이다. 3 객체와참조 Account

More information

Microsoft PowerPoint - Introduction to Google Guava.pptx

Microsoft PowerPoint - Introduction to Google Guava.pptx 2012 년자바카페 OPEN 세미나 주제 : Introduction to Google Guava 2012. 6. 16 김흥래 hrkim3468@gmail.com Java Developer s Forum JavaCafe community 구아바???? Java Developer s Forum JavaCafe Community 소개 Google Core Library

More information

PowerPoint Presentation

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

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

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

Microsoft PowerPoint 장.객체의이용.ppt

Microsoft PowerPoint 장.객체의이용.ppt 객체의이용 지난강의에서우리는상자에대한모델을다루었다 : class Box { int Length; int Width; int Height; public void setlength (int NewLength) { Length = NewLength; public int getlength ( ) { return (Length); public void setwidth

More information

<4D F736F F F696E74202D20C1A63234C0E520C0D4C3E2B7C228B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

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

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

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

Microsoft PowerPoint - lec2.ppt

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

More information

JVM 메모리구조

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

More information

No Slide Title

No Slide Title 상속 이충기 명지대학교컴퓨터공학과 상속 Q: 건설회사는기존아파트와조금다르거나추가적인특징들을가진새아파트를지을때어떻게하는가? A: 2 상속 상속 (inheritance) 은클래스들을연관시키는자연스럽고계층적인방법이다. 상속은객체지향프로그래밍의가장중요한개념중의하나이다. 상속은 은 이다 라는관계 (is-a relationship) 를나타낸다. 이관계를적용하여클래스들을상하관계로연결하는것이상속이다.

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

객체 Key Point 객체는그객체의특성을나타내는상태 (state) 와그객체의행동 (behaviors) 으로이루어진다. 좌표상의점 n 상태 : x 좌표값, y 좌표값 n 행동 : 점의이동 주사위 n 상태 : 표면값 n 행동 : 주사위굴리기 은행계좌 n 상태 : 예금주,

객체 Key Point 객체는그객체의특성을나타내는상태 (state) 와그객체의행동 (behaviors) 으로이루어진다. 좌표상의점 n 상태 : x 좌표값, y 좌표값 n 행동 : 점의이동 주사위 n 상태 : 표면값 n 행동 : 주사위굴리기 은행계좌 n 상태 : 예금주, 제 5 장객체와클래스 Kwangman Man (htt://comiler.sangji.ac.kr, kkman@sangji.ac.kr) SangJi University 2012 1 이장의내용 객체와클래스의기본개념 클래스사용법 클래스를정의하는방법 메소드를구현하는방법 가시성및접근제어 GUI 프로그램의이해및작성 2 5.1 객체와클래스 3 1 객체 Key Point 객체는그객체의특성을나타내는상태

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

4장.문장

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

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

Microsoft PowerPoint - CSharp-2-기초문법

Microsoft PowerPoint - CSharp-2-기초문법 2 장. C# 기초문법 자료형 제어문 배열 연산자 순천향대학교컴퓨터학부이상정 1 자료형 순천향대학교컴퓨터학부이상정 2 CTS CTS(Common Type System) 닷넷기반의여러언어에서공통으로사용되는자료형 언어별로서로다른자료형을사용할때발생할수있는호환성문제를해결 값 (Value) 형과참조 (Reference) 형을지원 CTS가제공하는모든자료형은 System.Object를상속받아구현

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

슬라이드 1

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

More information

PowerPoint Template

PowerPoint Template 16-1. 보조자료템플릿 (Template) 함수템플릿 클래스템플릿 Jong Hyuk Park 함수템플릿 Jong Hyuk Park 함수템플릿소개 함수템플릿 한번의함수정의로서로다른자료형에대해적용하는함수 예 int abs(int n) return n < 0? -n : n; double abs(double n) 함수 return n < 0? -n : n; //

More information

슬라이드 1

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

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 - lec02_ ppt [호환 모드]

Microsoft PowerPoint - lec02_ ppt [호환 모드] JAVA 프로그래밍 2. 기본문법 한동일 학습목표 To learn about identifier To learn about primitive type To understand the proper use of literals To use the String type to define and manipulate character strings To understand

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

01-OOPConcepts(2).PDF

01-OOPConcepts(2).PDF Object-Oriented Programming Concepts Tel: 02-824-5768 E-mail: hhcho@selabsoongsilackr? OOP (Object) (Encapsulation) (Message) (Class) (Inheritance) (Polymorphism) (Abstract Class) (Interface) 2 1 + = (Dependency)

More information

선형대수학 Linear Algebra

선형대수학  Linear Algebra 배열, 컬렉션, 인덱서 array, collection, indexer 소프트웨어학과 HCI 프로그래밍강좌 배열 배열 (array) 동일한자료형을다수선언 선언형식 데이터형식 [ ] 배열이름 = new 데이터형식 [ 개수 ]; int[ ] array = new int[5]; 인덱스 (index) 는 0 에서시작 scores[0] = 80; scores[1] =

More information

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 6 강. 함수와배열, 포인터, 참조목차 함수와포인터 주소값의매개변수전달 주소의반환 함수와배열 배열의매개변수전달 함수와참조 참조에의한매개변수전달 참조의반환 프로그래밍연습 1 /15 6 강. 함수와배열, 포인터, 참조함수와포인터 C++ 매개변수전달방법 값에의한전달 : 변수값,

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

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

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

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

CHAPTER 02 데이터형과수식 JAVA Programing

CHAPTER 02 데이터형과수식 JAVA Programing CHAPTER 02 데이터형과수식 JAVA Programing 개요 학습목표 4가지기본데이터형과변수의선언및할당방법연산자들과연산식의사용법간단하게입출력을하는방법 목차 데이터형변수의선언과초기화식별자와예약어연산자와연산식간단한입출력 개요 메모장과 DOS 창에서프로그래밍 객체지향이후이클립스사용 메모장과 DOS 창을연다.(notepad, cmd) DOS 명령어 디렉토리이동

More information

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 5 강. 배열, 포인터, 참조목차 배열 포인터 C++ 메모리구조 주소연산자 포인터 포인터연산 배열과포인터 메모리동적할당 문자열 참조 1 /20 5 강. 배열, 포인터, 참조배열 배열 같은타입의변수여러개를하나의변수명으로처리 int Ary[10]; 총 10 개의변수 : Ary[0]~Ary[9]

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 13. 포인터와배열! 함께이해하기 2013.10.02. 오병우 컴퓨터공학과 13-1 포인터와배열의관계 Programming in C, 정재은저, 사이텍미디어. 9 장참조 ( 교재의 13-1 은읽지말것 ) 배열이름의정체 배열이름은 Compile 시의 Symbol 로서첫번째요소의주소값을나타낸다. Symbol 로서컴파일시에만유효함 실행시에는메모리에잡히지않음

More information

Microsoft PowerPoint - chap03-변수와데이터형.pptx

Microsoft PowerPoint - chap03-변수와데이터형.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 학습목표 의 개념에 대해 알아본다.

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

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

교육자료

교육자료 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

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

OCW_C언어 기초

OCW_C언어 기초 초보프로그래머를위한 C 언어기초 4 장 : 연산자 2012 년 이은주 학습목표 수식의개념과연산자및피연산자에대한학습 C 의알아보기 연산자의우선순위와결합방향에대하여알아보기 2 목차 연산자의기본개념 수식 연산자와피연산자 산술연산자 / 증감연산자 관계연산자 / 논리연산자 비트연산자 / 대입연산자연산자의우선순위와결합방향 조건연산자 / 형변환연산자 연산자의우선순위 연산자의결합방향

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

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 제 8 장. 포인터 목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 포인터의개요 포인터란? 주소를변수로다루기위한주소변수 메모리의기억공간을변수로써사용하는것 포인터변수란데이터변수가저장되는주소의값을 변수로취급하기위한변수 C 3 포인터의개요 포인터변수및초기화 * 변수데이터의데이터형과같은데이터형을포인터 변수의데이터형으로선언 일반변수와포인터변수를구별하기위해

More information

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Function) 1. 함수의개념 입력에대해적절한출력을발생시켜주는것 내가 ( 프로그래머 ) 작성한명령문을연산, 처리, 실행해주는부분 ( 모듈 ) 자체적으로실행되지않으며,

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

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