SlideShare a Scribd company logo
1 of 49
Download to read offline
2시간 만에 자바를
쉽게 배우고 싶어요.
OKdevTV.com/mib/java
kenu.heo@gmail.com
첫 시간
1. 구구단을 만들자 (변수, 반복문, 조건문)
2. 관등성명을 대라 (메소드와 클래스, 패키지)
3. 이용하자. 자바 라이브러리 (jar)
프로그램이란
•컴퓨터에게 일 시키기 위한 명령 집합
•소스와 바이너리
•소스를 바이너리로 만드는 컴파일러
java? 뭘 자바?
•coffee?
•프로그램 언어
•1995년 제임스 고슬링
•James Gosling
•Sun
Microsystems
•Java Creator
Java is NOT JavaScript
구구단을 만들자
•2 x 1 = 2
•System.out.println("2 x 1 = 2");
기본 틀
public class Gugudan {
public static void main(String[] args) {
System.out.println("2 * 1 = 2");
}
}
keyword
•클래스 (class)
•메소드 (method)
•명령문 (statement)
기본 틀
public class Gugudan {
public static void main(String[] args) {
System.out.println("2 * 1 = 2");
}
}
클래스
메소드
명령문
컴파일
•java compiler
•javac
•JAVA_HOME/bin/javac.exe or javac
•javac -d . simple.Gugudan.java
•tool super easy
실행
•java simple.Gugudan
2 * 1 = 2
문자열 (String)
public class Gugudan {
public static void main(String[] args) {
System.out.println("2 * 1 = 2");
}
}
문자열 더하기
public class Gugudan {
public static void main(String[] args) {
System.out.println("2" + " * 1 = 2");
}
}
문자열 더하기
public class Gugudan {
public static void main(String[] args) {
System.out.println( 2 + " * 1 = 2");
}
}
변수
public class Gugudan {
public static void main(String[] args) {
int i = 2;
System.out.println( i + " * 1 = 2");
}
}
변수
public class Gugudan {
public static void main(String[] args) {
int i = 2;
int j = 1;
System.out.println( i + " * " + j + " = 2");
}
}
반복(loop)
public class Gugudan {
public static void main(String[] args) {
int i = 2;
for (int j = 1; j <= 9; j = j + 1) {
System.out.println( i + " * " + j + " = 2");
}
}
}
실행
•java simple.Gugudan
2 * 1 = 2
2 * 2 = 2
2 * 3 = 2
2 * 4 = 2
2 * 5 = 2
2 * 6 = 2
2 * 7 = 2
2 * 8 = 2
2 * 9 = 2
연산 (operation)
•더하기
•빼기
•곱하기
•나누기
•나머지
연산 (operation)
•더하기 +
•빼기 -
•곱하기 *
•나누기 /
•나머지 % (5 % 3 = 2)
연산
public class Gugudan {
public static void main(String[] args) {
int i = 2;
for (int j = 1; j <= 9; j = j + 1) {
int k = i * j;
System.out.println(i + " * " + j + " = " + k);
}
}
}
실행
•java simple.Gugudan
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
구구단 완성
public class Gugudan {
public static void main(String[] args) {
for (int i = 2; i <= 9; i = i + 1) {
for (int j = 1; j <= 9; j = j + 1) {
int k = i * j;
System.out.println( i + " * " + j + " = " + k);
}
}
}
}
실행
•java simple.Gugudan
2 * 1 = 2
2 * 2 = 4
...
2 * 8 = 16
2 * 9 = 18
3 * 1 = 3
3 * 2 = 6
...
9 * 8 = 72
9 * 9 = 81
관등성명을 대라
package simple;
public class Gugudan {
public static void main(String[] args) {
for (int i = 2; i <= 9; i = i + 1) {
for (int j = 1; j <= 9; j = j + 1) {
int k = i * j;
System.out.println( i + " * " + j + " = " + k);
}
}
}
}
클래스
메소드
명령문
명령문
명령문
명령문
패키지
패키지(package)
•김 영수
•김 : package, family group
•영수 : class
•고 영수, 이 영수, 최 영수
클래스 (class)
•Type
•도장
•Object
•attributes
•methods
클래스 (class)
•메모리 할당 필요 (static, new)
•인스턴스: 메모리 할당 받은 객체
메소드 (method)
•do
•f(x)
•명령문 그룹
•입력과 반환
메소드 (method)
package simple;
public class Gugudan {
public static void main(String[] args) {
for (int i = 2; i <= 9; i = i + 1) {
printDan(i);
}
}
...
메소드(method)
...
public static void printDan(int i) {
for (int j = 1; j <= 9; j = j + 1) {
int k = i * j;
System.out.println( i + " * " + j + " = " + k);
}
}
} // class end
메소드 Outline
package simple;
public class Gugudan {
public static void main(String[] args) {...}
public static void printDan(int i) {...}
}
메소드 signature
•public static void main(String[] args)
•public: 접근자 private, protected
•static: 메모리 점유 (optional)
•void: return type 없음
•main: 메소드 이름
•String[] args: 파라미터
Bonus
public static void main(String[] args) {
System.out.println("gugudan from:");
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
for (; i <= 9; i = i + 1) {
printDan(i);
}
}
이용하자
자바 라이브러리 jar
•클래스 모음
•jar: Java ARchive(기록 보관)
•zip 알고리즘
•tar와 유사 (Tape ARchive)
jar 만들기
•jar cvf gugudan.jar *
•jar xvf: 풀기
•jar tvf: 목록 보기
•META-INF/MANIFEST.MF
•jar 파일의 버전 등의 정보
•실행 클래스 설정
•제외 옵션: cvfM
MANIFEST.MF
• Manifest-Version: 1.0
• Class-Path: .
• Main-Class: simple.Gugudan
jar 활용
•java -jar gugudan.jar
•java -classpath .;c:libsgugudan.jar;
okjsp.chap01.Gugudan
두번째 시간
•아빠가 많이 도와줄께 (상속)
•클래스 간의 약속 (인터페이스)
•잘 안될 때, 버그 잡는 법 (예외 처리, 디버깅)
아빠가 많이 도와줄께
(상속)
•여러 클래스의 공통 부분
•java.lang.Object
•equals(), toString(), hashCode()
Father, Son, Daughter
• Father class
• Son, Daughter classes
• Son extends Father {}
• Daughter extends Father {}
• 아빠꺼 다 내꺼
클래스 간의 약속
(인터페이스)
•interface
•구현은 나중에
•파라미터는 이렇게 넘겨 줄테니
•이렇게 반환해 주세요
•실행은 안 되어도 컴파일은 된다
인터페이스 구현
implements
•클래스 implements PromiseInterface
•이것만 지켜주시면 됩니다
•이 메소드는 이렇게 꼭 구현해주세요
인터페이스 장점
• interface가 같으니까
• 테스트 클래스로 쓱싹 바꿀 수 있어요
• 바꿔치기의 달인
• 전략 패턴, SpringFramework, JDBC Spec
잘 안될 때, 버그잡는 법
(예외 처리, 디버깅)
•변수가
•내 생각대로 움직이지 않을 때
디버그 (debug)
•de + bug
•약을 뿌릴 수도 없고
디버그 (debug)
•중단점 (break point)
•변수의 메모리값 확인
•한 줄 실행
•함수 안으로
•함수 밖으로
•계속 실행
더 배워야 할 것들
• 배열
• 데이터 컬렉션 프레임워크
• 객체지향의 특성
• 자바 웹 (JSP/Servlet)
• 데이터베이스 연결
• 자바 오픈소스 프레임워크
• ...

More Related Content

What's hot

Créer des applications Java avec MongoDB
Créer des applications Java avec MongoDBCréer des applications Java avec MongoDB
Créer des applications Java avec MongoDBMongoDB
 
도메인 주도 설계의 본질
도메인 주도 설계의 본질도메인 주도 설계의 본질
도메인 주도 설계의 본질Young-Ho Cho
 
Java 8 - collections et stream
Java 8 - collections et streamJava 8 - collections et stream
Java 8 - collections et streamFranck SIMON
 
iOS Modular Architecture with Tuist
iOS Modular Architecture with TuistiOS Modular Architecture with Tuist
iOS Modular Architecture with Tuist정민 안
 
Introduction to React Native Workshop
Introduction to React Native WorkshopIntroduction to React Native Workshop
Introduction to React Native WorkshopIgnacio Martín
 
iOS Application Lifecycle
iOS Application LifecycleiOS Application Lifecycle
iOS Application LifecycleSiva Prasad K V
 
Presentation JEE et son écossystéme
Presentation JEE et son écossystémePresentation JEE et son écossystéme
Presentation JEE et son écossystémeAlgeria JUG
 
Angular Framework présentation PPT LIGHT
Angular Framework présentation PPT LIGHTAngular Framework présentation PPT LIGHT
Angular Framework présentation PPT LIGHTtayebbousfiha1
 
A la découverte de vue.js
A la découverte de vue.jsA la découverte de vue.js
A la découverte de vue.jsBruno Bonnin
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIICS
 
Présentation de JEE et de son écosysteme
Présentation de JEE et de son écosystemePrésentation de JEE et de son écosysteme
Présentation de JEE et de son écosystemeStéphane Traumat
 
Introduction à l’orienté objet en Python
Introduction à l’orienté objet en PythonIntroduction à l’orienté objet en Python
Introduction à l’orienté objet en PythonAbdoulaye Dieng
 
Ionic, AngularJS,Cordova,NodeJS,Sass
Ionic, AngularJS,Cordova,NodeJS,SassIonic, AngularJS,Cordova,NodeJS,Sass
Ionic, AngularJS,Cordova,NodeJS,Sassmarwa baich
 

What's hot (20)

Créer des applications Java avec MongoDB
Créer des applications Java avec MongoDBCréer des applications Java avec MongoDB
Créer des applications Java avec MongoDB
 
도메인 주도 설계의 본질
도메인 주도 설계의 본질도메인 주도 설계의 본질
도메인 주도 설계의 본질
 
Java 8 - collections et stream
Java 8 - collections et streamJava 8 - collections et stream
Java 8 - collections et stream
 
iOS Modular Architecture with Tuist
iOS Modular Architecture with TuistiOS Modular Architecture with Tuist
iOS Modular Architecture with Tuist
 
Introduction to React Native Workshop
Introduction to React Native WorkshopIntroduction to React Native Workshop
Introduction to React Native Workshop
 
iOS Application Lifecycle
iOS Application LifecycleiOS Application Lifecycle
iOS Application Lifecycle
 
Selenium
SeleniumSelenium
Selenium
 
Support JEE Servlet Jsp MVC M.Youssfi
Support JEE Servlet Jsp MVC M.YoussfiSupport JEE Servlet Jsp MVC M.Youssfi
Support JEE Servlet Jsp MVC M.Youssfi
 
Langage C#
Langage C#Langage C#
Langage C#
 
Presentation JEE et son écossystéme
Presentation JEE et son écossystémePresentation JEE et son écossystéme
Presentation JEE et son écossystéme
 
JAVA, JDBC et liaison base de données
JAVA, JDBC et liaison base de donnéesJAVA, JDBC et liaison base de données
JAVA, JDBC et liaison base de données
 
Angular Avancé
Angular AvancéAngular Avancé
Angular Avancé
 
Angular Framework présentation PPT LIGHT
Angular Framework présentation PPT LIGHTAngular Framework présentation PPT LIGHT
Angular Framework présentation PPT LIGHT
 
DDD 준비 서문래
DDD 준비 서문래DDD 준비 서문래
DDD 준비 서문래
 
A la découverte de vue.js
A la découverte de vue.jsA la découverte de vue.js
A la découverte de vue.js
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part III
 
Présentation de JEE et de son écosysteme
Présentation de JEE et de son écosystemePrésentation de JEE et de son écosysteme
Présentation de JEE et de son écosysteme
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Introduction à l’orienté objet en Python
Introduction à l’orienté objet en PythonIntroduction à l’orienté objet en Python
Introduction à l’orienté objet en Python
 
Ionic, AngularJS,Cordova,NodeJS,Sass
Ionic, AngularJS,Cordova,NodeJS,SassIonic, AngularJS,Cordova,NodeJS,Sass
Ionic, AngularJS,Cordova,NodeJS,Sass
 

Similar to Java in 2 hours

Java Virtual Machine, Call stack, Java Byte Code
Java Virtual Machine, Call stack, Java Byte CodeJava Virtual Machine, Call stack, Java Byte Code
Java Virtual Machine, Call stack, Java Byte CodeJavajigi Jaesung
 
2시간만에 자바 데이터처리를 쉽게 배우고 싶어요.
2시간만에  자바 데이터처리를 쉽게 배우고 싶어요.2시간만에  자바 데이터처리를 쉽게 배우고 싶어요.
2시간만에 자바 데이터처리를 쉽게 배우고 싶어요.Kenu, GwangNam Heo
 
Java mentoring of samsung scsc 2
Java mentoring of samsung scsc   2Java mentoring of samsung scsc   2
Java mentoring of samsung scsc 2도현 김
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)상욱 송
 
GCGC- CGCII 서버 엔진에 적용된 기술 (8) - Group System
GCGC- CGCII 서버 엔진에 적용된 기술 (8) - Group SystemGCGC- CGCII 서버 엔진에 적용된 기술 (8) - Group System
GCGC- CGCII 서버 엔진에 적용된 기술 (8) - Group System상현 조
 
Java reflection & introspection_SYS4U I&C
Java reflection & introspection_SYS4U I&CJava reflection & introspection_SYS4U I&C
Java reflection & introspection_SYS4U I&Csys4u
 
Java 강의자료 ed11
Java 강의자료 ed11Java 강의자료 ed11
Java 강의자료 ed11hungrok
 
Jdk(java) 7 - 5. invoke-dynamic
Jdk(java) 7 - 5. invoke-dynamicJdk(java) 7 - 5. invoke-dynamic
Jdk(java) 7 - 5. invoke-dynamicknight1128
 
파이썬 스터디 15장
파이썬 스터디 15장파이썬 스터디 15장
파이썬 스터디 15장SeongHyun Ahn
 
Web Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons Learned
Web Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons LearnedWeb Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons Learned
Web Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons LearnedJungsu Heo
 
Android ndk jni 설치및 연동
Android ndk jni 설치및 연동Android ndk jni 설치및 연동
Android ndk jni 설치및 연동Sangon Lee
 
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개
[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개PgDay.Seoul
 
2009 응용수학2 과제
2009 응용수학2 과제2009 응용수학2 과제
2009 응용수학2 과제Kyunghoon Kim
 
Multi-thread : producer - consumer
Multi-thread : producer - consumerMulti-thread : producer - consumer
Multi-thread : producer - consumerChang Yoon Oh
 

Similar to Java in 2 hours (20)

Java start01 in 2hours
Java start01 in 2hoursJava start01 in 2hours
Java start01 in 2hours
 
Java Virtual Machine, Call stack, Java Byte Code
Java Virtual Machine, Call stack, Java Byte CodeJava Virtual Machine, Call stack, Java Byte Code
Java Virtual Machine, Call stack, Java Byte Code
 
2시간만에 자바 데이터처리를 쉽게 배우고 싶어요.
2시간만에  자바 데이터처리를 쉽게 배우고 싶어요.2시간만에  자바 데이터처리를 쉽게 배우고 싶어요.
2시간만에 자바 데이터처리를 쉽게 배우고 싶어요.
 
Java mentoring of samsung scsc 2
Java mentoring of samsung scsc   2Java mentoring of samsung scsc   2
Java mentoring of samsung scsc 2
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)
 
GCGC- CGCII 서버 엔진에 적용된 기술 (8) - Group System
GCGC- CGCII 서버 엔진에 적용된 기술 (8) - Group SystemGCGC- CGCII 서버 엔진에 적용된 기술 (8) - Group System
GCGC- CGCII 서버 엔진에 적용된 기술 (8) - Group System
 
Scala for play
Scala for playScala for play
Scala for play
 
Java reflection & introspection_SYS4U I&C
Java reflection & introspection_SYS4U I&CJava reflection & introspection_SYS4U I&C
Java reflection & introspection_SYS4U I&C
 
Basic git-commands
Basic git-commandsBasic git-commands
Basic git-commands
 
Java_01 기초
Java_01 기초Java_01 기초
Java_01 기초
 
Java 기초
Java 기초Java 기초
Java 기초
 
Java 강의자료 ed11
Java 강의자료 ed11Java 강의자료 ed11
Java 강의자료 ed11
 
Jdk(java) 7 - 5. invoke-dynamic
Jdk(java) 7 - 5. invoke-dynamicJdk(java) 7 - 5. invoke-dynamic
Jdk(java) 7 - 5. invoke-dynamic
 
파이썬 스터디 15장
파이썬 스터디 15장파이썬 스터디 15장
파이썬 스터디 15장
 
Web Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons Learned
Web Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons LearnedWeb Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons Learned
Web Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons Learned
 
Android ndk jni 설치및 연동
Android ndk jni 설치및 연동Android ndk jni 설치및 연동
Android ndk jni 설치및 연동
 
Rx java essentials
Rx java essentialsRx java essentials
Rx java essentials
 
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개
[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개
 
2009 응용수학2 과제
2009 응용수학2 과제2009 응용수학2 과제
2009 응용수학2 과제
 
Multi-thread : producer - consumer
Multi-thread : producer - consumerMulti-thread : producer - consumer
Multi-thread : producer - consumer
 

More from Kenu, GwangNam Heo

이클립스 플랫폼
이클립스 플랫폼이클립스 플랫폼
이클립스 플랫폼Kenu, GwangNam Heo
 
채팅 소스부터 Https 주소까지
채팅 소스부터  Https 주소까지채팅 소스부터  Https 주소까지
채팅 소스부터 Https 주소까지Kenu, GwangNam Heo
 
개발자가 바라보는 자바의 미래 - 2018
개발자가 바라보는 자바의 미래 - 2018개발자가 바라보는 자바의 미래 - 2018
개발자가 바라보는 자바의 미래 - 2018Kenu, GwangNam Heo
 
오픈 소스 사용 매뉴얼
오픈 소스 사용 매뉴얼오픈 소스 사용 매뉴얼
오픈 소스 사용 매뉴얼Kenu, GwangNam Heo
 
소셜 코딩 GitHub & branch & branch strategy
소셜 코딩 GitHub & branch & branch strategy소셜 코딩 GitHub & branch & branch strategy
소셜 코딩 GitHub & branch & branch strategyKenu, GwangNam Heo
 
오픈소스 개요
오픈소스 개요오픈소스 개요
오픈소스 개요Kenu, GwangNam Heo
 
오픈소스 개발도구 2014
오픈소스 개발도구 2014오픈소스 개발도구 2014
오픈소스 개발도구 2014Kenu, GwangNam Heo
 
모바일 웹앱 프로그래밍 과정
모바일 웹앱 프로그래밍 과정모바일 웹앱 프로그래밍 과정
모바일 웹앱 프로그래밍 과정Kenu, GwangNam Heo
 
JavaScript 2014 프론트엔드 기술 리뷰
JavaScript 2014 프론트엔드 기술 리뷰JavaScript 2014 프론트엔드 기술 리뷰
JavaScript 2014 프론트엔드 기술 리뷰Kenu, GwangNam Heo
 
01이제는 모바일 세상이다
01이제는 모바일 세상이다01이제는 모바일 세상이다
01이제는 모바일 세상이다Kenu, GwangNam Heo
 

More from Kenu, GwangNam Heo (20)

이클립스 플랫폼
이클립스 플랫폼이클립스 플랫폼
이클립스 플랫폼
 
About Programmer 2021
About Programmer 2021About Programmer 2021
About Programmer 2021
 
채팅 소스부터 Https 주소까지
채팅 소스부터  Https 주소까지채팅 소스부터  Https 주소까지
채팅 소스부터 Https 주소까지
 
Dev team chronicles
Dev team chroniclesDev team chronicles
Dev team chronicles
 
개발자가 바라보는 자바의 미래 - 2018
개발자가 바라보는 자바의 미래 - 2018개발자가 바라보는 자바의 미래 - 2018
개발자가 바라보는 자바의 미래 - 2018
 
오픈 소스 사용 매뉴얼
오픈 소스 사용 매뉴얼오픈 소스 사용 매뉴얼
오픈 소스 사용 매뉴얼
 
about Programmer 2018
about Programmer 2018about Programmer 2018
about Programmer 2018
 
Cloud developer evolution
Cloud developer evolutionCloud developer evolution
Cloud developer evolution
 
Elastic stack
Elastic stackElastic stack
Elastic stack
 
Social Dev Trend
Social Dev TrendSocial Dev Trend
Social Dev Trend
 
소셜 코딩 GitHub & branch & branch strategy
소셜 코딩 GitHub & branch & branch strategy소셜 코딩 GitHub & branch & branch strategy
소셜 코딩 GitHub & branch & branch strategy
 
오픈소스 개요
오픈소스 개요오픈소스 개요
오픈소스 개요
 
Developer paradigm shift
Developer paradigm shiftDeveloper paradigm shift
Developer paradigm shift
 
Social Coding GitHub 2015
Social Coding GitHub 2015Social Coding GitHub 2015
Social Coding GitHub 2015
 
오픈소스 개발도구 2014
오픈소스 개발도구 2014오픈소스 개발도구 2014
오픈소스 개발도구 2014
 
Mean stack Start
Mean stack StartMean stack Start
Mean stack Start
 
모바일 웹앱 프로그래밍 과정
모바일 웹앱 프로그래밍 과정모바일 웹앱 프로그래밍 과정
모바일 웹앱 프로그래밍 과정
 
JavaScript 2014 프론트엔드 기술 리뷰
JavaScript 2014 프론트엔드 기술 리뷰JavaScript 2014 프론트엔드 기술 리뷰
JavaScript 2014 프론트엔드 기술 리뷰
 
jQuery 구조와 기능
jQuery 구조와 기능jQuery 구조와 기능
jQuery 구조와 기능
 
01이제는 모바일 세상이다
01이제는 모바일 세상이다01이제는 모바일 세상이다
01이제는 모바일 세상이다
 

Java in 2 hours