0. 발사믹 목업과 카카오에서 만든 오븐 목업을 사용한 적 있음. 컴포넌트가 다양하지 않고, 발사믹 목업은 영어에 흑백이라는 단점이 있음.

1. 기획자가 아닌 개발자 입장에서 접근성이나 장벽이 낮은 툴을 검색한 결과 파워포인트의 플러그인으로 파워목업이란 게 있다는 걸 확인.

2. 부트스트랩 느낌의 화면 설계나, 관리자 대시보드 페이지를 만들 때 유용한 Shapes들이 있는 걸 확인. 다만 그것들을 사용하려면(=좀 써보려고 하면) Download More Shapes를 눌러 그 Shapes를 다운받아야 함.

3. 다운받는다고 바로 쓸 수 있는 게 아니었음. 다운받은 테마 중 대부분은 사용할 수 없고, Buy Full Version을 눌러 인당 약 60달러를 (평생 사용) 결제해야 함.

4. 결제가 부담스럽다면 마이크로소프트 MVP 사용자이거나, 파워목업에 대한 소개 및 리뷰가 담긴 블로그를 작성 후 제작자에게 블로그 주소와 이름을 담아 이메일(support@powermockup.com)을 보내면 License Code를 보내준다 하여 이 글을 작성함.

5. 사용 방법: 아래 주소로 들어가 체험판(으로 사용 시 기능이 제한됨)을 다운받아 사용해본다.

www.powermockup.com/

 

PowerPoint Wireframe and Prototyping Tool | PowerMockup

Collaboration PowerPoint includes collaboration and sharing features that facilitate working in a team. You can share documents with others via OneDrive or SharePoint, leave comments on slides, and merge different versions of a document into a single file.

www.powermockup.com

 

0422
HTML
- HyperText Markup Language
* HyperText: 문서의 링크를 클릭하면 연결된 다른 문서로 이동할 수 있는 기능을 제공하는 텍스트
* Markup: 문서의 어느 부분이 제목이고, 어느 부분이 본문이고, 어느 부분이 링크인지를 표시하기 위해서 특별한 기호(마크업, 태그)이 사용된다.
- 웹에서 웹 문서간에 빠르게 이동할 수 있는 문서를 만들 때 사용되는 언어가 HTML이다.

태그
- 태그는 '<'와 '>'로 구성된다.
* <body> <img> <table> <ul><br> - 태그의 이름은 소문자로 적는다.<br> - 태그는 여는 태그와 닫는 태그가 쌍으로 구성된다.<br> * 여는 태그: <table> <body> <head> <script type="text/javascript">if (!window.T) { window.T = {} } window.T.config = {"TOP_SSL_URL":"https://www.tistory.com","PREVIEW":false,"ROLE":"guest","PREV_PAGE":"","NEXT_PAGE":"","BLOG":{"id":1777466,"name":"monkey-k777","title":"N의 창고","isDormancy":false,"nickName":"monkey-k777","status":"open","profileStatus":"normal"},"NEED_COMMENT_LOGIN":false,"COMMENT_LOGIN_CONFIRM_MESSAGE":"","LOGIN_URL":"https://www.tistory.com/auth/login/?redirectUrl=https://monkey-k777.tistory.com/","DEFAULT_URL":"https://monkey-k777.tistory.com","USER":{"name":null,"homepage":null,"id":0,"profileImage":null},"SUBSCRIPTION":{"status":"none","isConnected":false,"isPending":false,"isWait":false,"isProcessing":false,"isNone":true},"IS_LOGIN":false,"HAS_BLOG":false,"IS_SUPPORT":false,"TOP_URL":"http://www.tistory.com","JOIN_URL":"https://www.tistory.com/member/join","ROLE_GROUP":"visitor"}; window.T.entryInfo = null; window.appInfo = {"domain":"tistory.com","topUrl":"https://www.tistory.com","loginUrl":"https://www.tistory.com/auth/login","logoutUrl":"https://www.tistory.com/auth/logout"}; window.initData = {}; window.TistoryBlog = { basePath: "", url: "https://monkey-k777.tistory.com", tistoryUrl: "https://monkey-k777.tistory.com", manageUrl: "https://monkey-k777.tistory.com/manage", token: "uFoWZCIK7u4FlgfKw+iG+r91AevsVlqhL8sfhrJ5YWp75S/bs80cZcXAWX/lnrGe" }; var servicePath = ""; var blogURL = "";</script> <br> * 닫는 태그: </table> <script type="text/javascript">(function($) { $(document).ready(function() { lightbox.options.fadeDuration = 200; lightbox.options.resizeDuration = 200; lightbox.options.wrapAround = false; lightbox.options.albumLabel = "%1 / %2"; }) })(tjQuery);</script> <div style="margin:0; padding:0; border:none; background:none; float:none; clear:none; z-index:0"></div> <script type="text/javascript" src="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-fda325030f650f8bb6efdfbc900c54d5af6cf662/static/script/common.js"></script> <script type="text/javascript">window.roosevelt_params_queue = window.roosevelt_params_queue || [{channel_id: 'dk', channel_label: '{tistory}'}]</script> <script type="text/javascript" src="//t1.daumcdn.net/midas/rt/dk_bt/roosevelt_dk_bt.js" async="async"></script> <script type="text/javascript" src="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-fda325030f650f8bb6efdfbc900c54d5af6cf662/static/script/menubar.min.js"></script> <script>window.tiara = {"svcDomain":"user.tistory.com","section":"홈","trackPage":"홈_보기","page":"홈","key":"1777466","customProps":{"userId":"0","blogId":"1777466","entryId":"null","role":"guest","trackPage":"홈_보기","filterTarget":false},"entry":null,"kakaoAppKey":"3e6ddd834b023f24221217e370daed18","appUserId":"null"}</script> <script type="module" src="https://t1.daumcdn.net/tistory_admin/frontend/tiara/v1.0.0/index.js"></script> <script src="https://t1.daumcdn.net/tistory_admin/frontend/tiara/v1.0.0/polyfills-legacy.min.js" nomodule="true" defer="true"></script> <script src="https://t1.daumcdn.net/tistory_admin/frontend/tiara/v1.0.0/index-legacy.js" nomodule="true" defer="true"></script> </body> <style type="text/css">.another_category { border: 1px solid #E5E5E5; padding: 10px 10px 5px; margin: 10px 0; clear: both; } .another_category h4 { font-size: 12px !important; margin: 0 !important; border-bottom: 1px solid #E5E5E5 !important; padding: 2px 0 6px !important; } .another_category h4 a { font-weight: bold !important; } .another_category table { table-layout: fixed; border-collapse: collapse; width: 100% !important; margin-top: 10px !important; } * html .another_category table { width: auto !important; } *:first-child + html .another_category table { width: auto !important; } .another_category th, .another_category td { padding: 0 0 4px !important; } .another_category th { text-align: left; font-size: 12px !important; font-weight: normal; word-break: break-all; overflow: hidden; line-height: 1.5; } .another_category td { text-align: right; width: 80px; font-size: 11px; } .another_category th a { font-weight: normal; text-decoration: none; border: none !important; } .another_category th a.current { font-weight: bold; text-decoration: none !important; border-bottom: 1px solid !important; } .another_category th span { font-weight: normal; text-decoration: none; font: 10px Tahoma, Sans-serif; border: none !important; } .another_category_color_gray, .another_category_color_gray h4 { border-color: #E5E5E5 !important; } .another_category_color_gray * { color: #909090 !important; } .another_category_color_gray th a.current { border-color: #909090 !important; } .another_category_color_gray h4, .another_category_color_gray h4 a { color: #737373 !important; } .another_category_color_red, .another_category_color_red h4 { border-color: #F6D4D3 !important; } .another_category_color_red * { color: #E86869 !important; } .another_category_color_red th a.current { border-color: #E86869 !important; } .another_category_color_red h4, .another_category_color_red h4 a { color: #ED0908 !important; } .another_category_color_green, .another_category_color_green h4 { border-color: #CCE7C8 !important; } .another_category_color_green * { color: #64C05B !important; } .another_category_color_green th a.current { border-color: #64C05B !important; } .another_category_color_green h4, .another_category_color_green h4 a { color: #3EA731 !important; } .another_category_color_blue, .another_category_color_blue h4 { border-color: #C8DAF2 !important; } .another_category_color_blue * { color: #477FD6 !important; } .another_category_color_blue th a.current { border-color: #477FD6 !important; } .another_category_color_blue h4, .another_category_color_blue h4 a { color: #1960CA !important; } .another_category_color_violet, .another_category_color_violet h4 { border-color: #E1CEEC !important; } .another_category_color_violet * { color: #9D64C5 !important; } .another_category_color_violet th a.current { border-color: #9D64C5 !important; } .another_category_color_violet h4, .another_category_color_violet h4 a { color: #7E2CB5 !important; } </style> <link rel="stylesheet" type="text/css" href="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-fda325030f650f8bb6efdfbc900c54d5af6cf662/static/style/revenue.css"/> <link rel="canonical" href="https://monkey-k777.tistory.com"/> <!-- BEGIN STRUCTURED_DATA --> <script type="application/ld+json"> {"@context":"http://schema.org","@type":"WebSite","url":"/","potentialAction":{"@type":"SearchAction","target":"/search/{search_term_string}","query":"required name=search_term_string"}} </script> <!-- END STRUCTURED_DATA --> <link rel="stylesheet" type="text/css" href="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-fda325030f650f8bb6efdfbc900c54d5af6cf662/static/style/dialog.css"/> <link rel="stylesheet" type="text/css" href="//t1.daumcdn.net/tistory_admin/www/style/top/font.css"/> <link rel="stylesheet" type="text/css" href="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-fda325030f650f8bb6efdfbc900c54d5af6cf662/static/style/postBtn.css"/> <link rel="stylesheet" type="text/css" href="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-fda325030f650f8bb6efdfbc900c54d5af6cf662/static/style/comment.css"/> <link rel="stylesheet" type="text/css" href="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-fda325030f650f8bb6efdfbc900c54d5af6cf662/static/style/tistory.css"/> <script type="text/javascript" src="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-fda325030f650f8bb6efdfbc900c54d5af6cf662/static/script/common.js"></script> <script type="text/javascript" src="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-fda325030f650f8bb6efdfbc900c54d5af6cf662/static/script/comment.js" defer=""></script> </head><br> - 여는 태그와 닫는 태그 사이에는 컨텐츠나 다른 태그가 포함될 수 있다.<br> * <h1>html 태그 연습</h1><br> * <p>html은 웹 문서를 만들 때 사용되는 언어다.</p><br> * <p><span>1위</span>방탄소년단</p><br> - 태그는 속성을 가질 수 있다.<br> * 속성은 속성명="속성값"으로 구성된다.<br> * <img src="images/cat.jpg" width="300" height="200" alt="예쁜 고양이"><br> - 태그간의 포함관계를 정확하게 표현해야 된다.<br> * <div><p>태그안에 다른 태그가 포함될 때는 여는 태그와 닫는 태그의 쌍을 맞춰야 한다.</p></div></p> <ul><li></li></ul> <p>html의 기본 구조<br><!doctype html></p> <html> <head> <script type="text/javascript">if (!window.T) { window.T = {} } window.T.config = {"TOP_SSL_URL":"https://www.tistory.com","PREVIEW":false,"ROLE":"guest","PREV_PAGE":"","NEXT_PAGE":"","BLOG":{"id":1777466,"name":"monkey-k777","title":"N의 창고","isDormancy":false,"nickName":"monkey-k777","status":"open","profileStatus":"normal"},"NEED_COMMENT_LOGIN":false,"COMMENT_LOGIN_CONFIRM_MESSAGE":"","LOGIN_URL":"https://www.tistory.com/auth/login/?redirectUrl=https://monkey-k777.tistory.com/","DEFAULT_URL":"https://monkey-k777.tistory.com","USER":{"name":null,"homepage":null,"id":0,"profileImage":null},"SUBSCRIPTION":{"status":"none","isConnected":false,"isPending":false,"isWait":false,"isProcessing":false,"isNone":true},"IS_LOGIN":false,"HAS_BLOG":false,"IS_SUPPORT":false,"TOP_URL":"http://www.tistory.com","JOIN_URL":"https://www.tistory.com/member/join","ROLE_GROUP":"visitor"}; window.T.entryInfo = null; window.appInfo = {"domain":"tistory.com","topUrl":"https://www.tistory.com","loginUrl":"https://www.tistory.com/auth/login","logoutUrl":"https://www.tistory.com/auth/logout"}; window.initData = {}; window.TistoryBlog = { basePath: "", url: "https://monkey-k777.tistory.com", tistoryUrl: "https://monkey-k777.tistory.com", manageUrl: "https://monkey-k777.tistory.com/manage", token: "uFoWZCIK7u4FlgfKw+iG+r91AevsVlqhL8sfhrJ5YWp75S/bs80cZcXAWX/lnrGe" }; var servicePath = ""; var blogURL = "";</script> <meta charset="utf-8" /> <title>처음으로 작성하는 html 문서

문서의 제목을 포함한다.

내용을 포함한다.

* : 현재 문서가 html5 작성 규칙에 맞춰서 작성된 웹 문서임을 나타낸다. * ~ : 웹 문서의 시작과 끝을 나타낸다. * ~ : 웹브라우저가 웹 문서를 해석하는데 필요한 정보를 입력하는 부분이다. 이 부분에 있는 정보는 실제 문서 내용이 아니기 때문에 화면에 표시되지 않는다. * ~
: 실제로 웹 브라우저에 표시되는 내용을 포함한다. 우리가 배우는 거의 대부분의 태그는 태그 안에 들어간다. *
: 줄 바꾸기. 콘텐츠를 포함하지 않음. 열자마자 닫는다. 브라우저: html 문서 -> 파싱(해석) -> Document 객체 생성 -> 태그마다 엘리먼트 객체 생성 -> 렌더링 -> 화면에 표시

0423
블록 엘리먼트(block element)와 인라인 엘리먼트(inline element)
- html 태그(엘리먼트)는 블록 엘리먼트와 인라인 엘리먼트로 나뉜다.
- 블록 엘리먼트는 인라인 엘리먼트로, 인라인 엘리먼트는 블록 엘리먼트로 바꿀 수 있다.
- 블록 엘리먼트
- 언제나 새로운 줄에서 시작한다.
- 좌우 양쪽으로 최대한 늘어나 가능한 모든 너비를 차지한다.
- 폭을 지정할 수 있다.
- 블록 엘리먼트 내의 콘텐츠를 왼쪽/오른쪽/가운데 정렬시킬 수 있다.
- div, h1 ~ h6, p, table, ul, ol, li, dl, dt, dd, form
- 인라인 엘리먼트
- 콘텐츠의 흐름을 끊지 않는다.
- 새로운 줄을 만들지 않고, 콘텐츠가 필요한 너비만 차지한다.
- span, a, img, strong, em, input, select, textarea, label, button
* 인라인 엘리먼트는 단독으로 표시되지 않는다.
인라인 엘리먼트는 블록 엘리먼트 안에 있어야 된다.

div, span 엘리먼트
- 통용 컨테이너 태그(엘리먼트다).
- CSS로 꾸미기 전에는 콘텐츠나 레이아웃에 어떤 영향도 주지 않는다.
- div 태그
- 블록 엘리먼트다.
- div나 다른 블록 엘리먼트, 인라인 엘리먼트들을 콘텐츠로 가진다.
- 여러 엘리먼트(태그)를 묶어서 스타일의 지정을 돕는 용도로 사용된다.
- 여러 엘리먼트(태그)를 묶어서 특정 영역으로 구분하는 용도로 사용된다.
- span 태그
- 인라인 엘리먼트다.
- 텍스트 콘텐츠를 묶어서 스타일의 지정을 돕는 용도로 사용된다.

id, class 속성
- 모든 엘리먼트(태그)는 id속성과 class속성을 가질 수 있다.
- id 속성은 해당 엘리먼트(태그)를 다른 엘리먼트와 구별하기 위해서 사용한다.
* html문서 안에 동일한 id속성값을 갖는 엘리먼트가 없어야 한다.
* id 속성값으로 특수문자를 사용할 수 없다.("_"와 "-"는 사용가능하다.)
* id 속성값은 문자(영어 대소문자)와 숫자를 사용할 수 있고, 숫자로 시작할 수 없다.
- class 속성은 엘리먼트(태그)에 동일한 스타일을 적용할 목적으로 사용한다.
* html 문서 안에 동일한 스타일이 적용될 엘리먼트는 동일한 class 속성값을 가지게 한다.
* class 속성값은 하나 이상의 값을 가질 수 있다.



버튼을 생성할 때 사용한다.

- input 태그
    - type 속성값에 따라서 다양한 입력 콘트롤을 생성할 수 있다.
    - 주요 타입 속성
        type="hidden"       사용자에게 보이지 않는 필드를 만든다.
        type="text"          한 줄 입력 텍스트필드를 만든다.
        type="password"   비밀번호 입력필드를 만든다.
        type="date"         날짜 입력 필드를 만든다.
        type="time"         시간 입력 필드를 만든다.
        type="number"     숫자 입력 필드를 만든다.
        type="email"        이메일 입력 필드를 만든다.
        type="url"            url 입력 필드를 만든다.
        type="file"           파일을 첨부할 수 있는 필드를 만든다.
        type="checkbox"  주어진 항목을 2개 이상 선택할 수 있는 체크박스를 만든다.
        type="radio"         주어진 항목에서 하나만 선택할 수 있는 라디오버튼을 만든다.
        type="submit"       입력된 값을 서버로 제출하는 버튼을 만든다.
        type="reset"        폼의 입력값을 원래 상태로 되돌리는 버튼을 만든다.
        type="button"       버튼을 만든다.
    - 주요 속성
        - type 속성: 입력 콘트롤의 형식을 지정한다.
        - name 속성: 입력된 값을 서버로 전송할 때 사용된다(필수).
        - id 속성: 입력 콘트롤을 식별하기 위해서 사용된다.
        - readonly 속성: 읽기 전용 입력 콘트롤로 만든다. 값을 변경할 수 없다.
        - disabled 속성:입력 콘트롤을 비활성화 시킨다. 값을 변경할 수 없고, 해당 입력 콘트롤의 같은 서버로 전송되지 않는다.
        - placeholder: 입력값 힌트를 제공한다.
        - maxlength: 최대 입력 문자 개수를 지정한다.
        - value: 입력값을 지정한다.
        - checked: 라디오버튼, 체크박스를 미리 선택되게 한다.

- select 태그
    - 콤보박스 생성
    - 사용자가 값을 입력하는 대신 나열된 값 중에 하나를 선택하도록 하는 드롭다운 목록을 생성한다.
       <select name="서버에전달할이름">
           <option value="값1">내용</option>
           <option value="값2">내용</option>
           <option value="값3">내용</option>
           <option value="값4">내용</option>
       </select>
        * 서버에는 선택된 옵션의 value에 설정된 값이 전달된다. 내용이 전달되지 않는다.
        - option태그의 주요 속성
            value: 서버로 전달될 값을 설정한다.
            disabled: 해당 항목을 선택하지 못하게 한다.
            selected: 해당 항목이 미리 선택되어 있게 한다.

    - textarea 태그
        - 여러 줄을 입력할 수 있는 텍스트영역을 만든다.
        - 주요 속성
            rows: 텍스트 영역의 세로 길이(행의 길이)를 설정한다.
            cols: 텍스트 영역의 가로 길이(문자 길이)를 설정한다.

'html' 카테고리의 다른 글

sample19~27(div, span, id, class, form 등)  (0) 2019.06.09
sample14~18(link, text, element)  (0) 2019.06.09
sample8~13 (table, img)  (0) 2019.06.09
sample1~7(title, text, list, table)  (0) 2019.06.09

VO/DAO 패턴
    VO(Value Object)
    - 데이터 베이스의 한 레코드를 담는 객체
    - 필드, 생성자, Getter/Setter 메소드 구성
    - 레코드(행)의 개수만큼 생성해서 사용한다.
    * VO객체, Domain객체, DTO객체, 자바 빈즈라고 부른다.

    DAO(Database Access Object)
    - Database Access 작업을 담당하는 객체
    - 추가/삭제/변경/조회 작업과 관련된 메소드들로 구성
    * CRUD 기능을 구현한다.
    * Create, Retrieve(조회), Update, Delete
    - 업무 로직이 존재하지 않는다.
    * 단순한 JDBC 코딩만 존재한다.
    * ibatis/mybatis/hibernate/jpa 등의 DB Access 작업을 단순화시켜주는 프레임워크를 활용해서 주로 개발된다.

    Service
    - 업무 로직을 관련된 작업을 담당하는 객체
    - 사용자가 입력한 값을 전달받아서 적절한 업무로직을 수행하고 업무 로직의 수행 결과를 DAO를 활용해서 DB에 영구적으로 보관한다.
    * 업무 로직은 보통 1번 이상의 DB Access 작업을 필요로 한다.
    * Service 객체의 메소드들은 DAO에 구현된 DB Access 작업을 실행해서 업무 로직에 필요한 정보를 획득하거나, 업무 로직의 수행 결과를 DB에 반영한다.


무결성 제약 조건
    - 테이블에 유효하지 않은 데이터가 저장되는 것을 방지한다.
    - 테이블에 행이 추가, 갱신, 삭제될 때마다 제약 규칙이 적용된다.
    - 제약 조건의 종류
       not null         제약 조건
                          해당 컬럼이 null값을 포함하지 못하도록 제약한다(이름).
       unique          제약 조건(고유키 제약 조건)
                          해당 컬럼의 값은 테이블의 모든 행에서 고유한 값을 가지는 컬럼 혹은 컬럼의 조합이어야 한다(이메일, 주민번호, 아이디)
       primary key   제약 조건(기본키 제약 조건)
                          해당 컬럼이 행을 대표하는 컬럼이 되도록 한다.
                          * null 값을 허용하지 않는다.
                          * 모든 행에 대해서 같이 고유해야 한다.
       foreign key    제약 조건(외래키 제약 조건)
                          해당 컬럼의 값이 동일한 테이블이나 다른 테이블의 기본키 혹은 고유키로 지정된 컬럼의 값을 참조하도록 한다
                         * 참조하는 컬럼의 값들만 저장되게 한다.
                         * not null 제약 조건이 지정되어 있지 않으면 null값도 허용한다.
       check           제약 조건
                         * 해당 컬럼의 값이 제시된 조건을 만족하는 값만 저장되도록 지정한다.

0415
트랜잭션
    - 데이터의 일관성을 보장하기 위해서 사용한다.
    - insert, update, delete 구문만 트랜잭션 처리의 대상이다.
    - 한 개 이상의 단일 작업(DB Access 작업)을 논리적 작업 그룹으로 묶어서 처리한다.

트랜잭션의 시작과 종료
    - 트랜잭션의 시작
        - 첫 번째 DML(INSERT, UPDATE, DELETE 구문) SQL이 실행될 때 자동으로 시작된다.
    - 트랜잭션의 종료
        - commit 또는 rollback 구문이 실행되면 자동으로 종료된다.
        - 시스템이 고장난 경우

commit과 rollback
    - commit은 해당 트랜잭션 내에서 실행된 dml 작업(데이터 변경 작업)을 영구 저장한다.
    - rollback은 해당 트랜잭션 내에서 실행된 dml 작업의 db 반영을 전부 취소한다.

트랜잭션 특징(ACID)
    - 원자성: 트랜잭션 내의 작업이 부분적으로 성공하거나 실패하는 것을 허용하지 않는 것. All or Nothing으로 동작
    - 일관성: 트랜잭션 내의 작업이 성공적으로 완료되었다면 언제나 일관성 있는 데이터 상태로 유지되는 것.
                  무결성 제약 조건을 위반하는 (일관성 있는 데이터 상태가 아닌 것) 트랜잭션은 실행될 수 없다.
    - 고립성: 트랜잭션 수행 시 다른 트랜잭션의 연산이 영향을 미치지 못하도록 하는 것
                  * 트랜잭션이 종료(완료)되기 전의 중간 상태의 데이터를 외부 트랜잭션이 볼 수 없음
    - 지속성: 성공적으로 수행된 트랜잭션의 결과는 데이터베이스에 영구적으로 반영된다.

오라클 데이터베이스 객체
    시퀀스: 일련번호 생성기
    테이블: 데이터의 저장소
    : 가상의 테이블이다.
         하나 이상의 테이블을 기반으로 하는 가상의 테이블이고, 자체적인 데이터를 포함하고 있지는 않지만, 테이블과 마찬가지로 뷰를 대상으로 CRUD가 가능하다.
         * 대부분 뷰를 대상으로는 SELECT만 사용한다.
         - 뷰를 사용하는 이유: 복잡한 SQL문을 쉽게 작성할 수 있다.
                                        데이터 엑세스를 제한할 수 있다.
                                        동일한 데이터로부터 다양한 결과를 얻을 수 있다.
    인덱스: 데이터의 색인 정보를 가지고 있다.

인라인 뷰(Inline View)
select ~
from ~
where 컬럼 = (select ~
                   from ~
                   where ~) <-- 서브 쿼리

select ~
from (select ~
       from ~
       where ~) <-- 인라인 뷰
where ~

select ~, (select ~ from ~ where ~) <-- 스칼라 서브 쿼리
from ~
where ~

인라인 뷰
    - 메인 쿼리의 from 절에 작성된 서브 쿼리를 말한다.
       * select문의 실행 결과가 가상의 테이블로 취급된다.
       * view는 오라클의 데이터베이스 객체이지만, 인라인 뷰는 오라클의 데이터베이스 객체가 아니다.
       * 메인 쿼리가 실행되는 동안 잠깐 만들어지는 가상의 테이블이다.
       - Top-N 분석 쿼리에 자주 사용된다.
       - 인라인 뷰도 조인에 참여할 수 있다.

Top-N 분석 쿼리
    - 테이블에서 조건에 맞는 최상위 데이터 n개 또는 최하위 데이터 n개를 조회할 때 사용된다.
        - 회사에 급여를 가장 많이 받는 직원 3명
        - 가장 최근에 입사한 직원 5명
        - 한 달 동안 가장 많이 팔린 제품 10가지
    - select 컬럼명, 컬럼명
      from (select 컬럼명, 컬럼명
             from 테이블
             order by Top-N 분석 대상_컬럼명)
        where rownum <= N
        * rownum은 서브쿼리(인라인뷰)에서 반환되는 각 행에 1부터 시작하는 순번을 할당한다.

분석 함수
    - 분석 대상 컬럼의 값을 기준으로 순번 혹은 순위를 부여하는 함수다.
       * ROW_NUMBER(): 순번을 부여한다.
       * RANK(): 순위를 부여한다.
    - Top-N 분석을 수행할 수 있다.
    - 특정 범위에 속한 행을 찾을 때 유리하다(6~10등).
    - 페이징 처리에 유용하게 사용되는 함수다.
    - 사용 방법: SELECT 분석함수() OVER (ODER BY 정렬대상컬럼명 정렬방향) 별칭, 컬럼명, 컬럼명
                    FROM 테이블명
                    * 정렬대상 컬럼의 값을 기준으로 행을 정렬한 다음 순번 혹은 순위를 부여한다.

0416
인덱스
    - 오라클 데이터베이스 테이블에서 원하는 데이터를 빠르게 찾아갈 수 있도록 만들어진 데이터 구조
    - 테이블의 데이터에 대한 색인 정보를 보관하고 있는 객체다.
    * 인덱스에 보관된 정보 = 데이터 + ROWID(데이터가 저장된 위치 정보)
    - 인덱스의 생성
        자동 생성 인덱스
            Primary key, unique 제약 조건이 정의된 컬럼은 자동으로 인덱스가 생성된다.
        수동 생성 인덱스
            create index 인덱스명
            on 테이블명(컬럼명, 컬럼명, ...)

    - 인덱스의 삭제
        drop index 인덱스명

    - 인덱스가 필요한 경우
        where절에 검색 조건으로 자주 사용되는 경우
        조인 조건으로 자주 사용되는 경우
        해당 컬럼에 null값이 많이 포함된 경우
        해당 컬럼에 다양한 값이 분포되어 있는 경우
        큰 테이블에서 대부분의 조회 조건으로 검색되는 행이 2%~4% 미만인 경우

    - rowid
        테이블에 저장된 데이터의 위치를 나타내는 주소값이다.
        사용자가 임의로 변경할 수 없고, 조회만 할 수 있다.
        예시: AAAEAW AAE AAAACt AAA
        AAAEAW: 데이터베이스 식별을 위한 Data Object Number
        AAE: 각각의 데이터파일에 할당된 File Number
        AAAACt: 데이터 블록의 위치를 나타내는 Block Number
        AAA: 블록 내에 데이터가 저장된 행의 번호 Row Number

사용자 및 권한 관리
    사용자
        - 데이터베이스 시스템에 접속하고, 데이터베이스 객체를 생성/삭제, 데이터 조작을 할 때 필요한 사용자 계정
        - 시스템 권한을 가진 사용자만 사용자를 등록/삭제할 수 있다.
            권한(privileges)
              - 특정 SQL문을 실행할 수 있는 권리
              - 시스템 권한
              - 데이터베이스 시스템을 사용(액세스)할 수 있는 권한
              - 시스템 권한을 가진 사용자만 부여/박탈이 가능하다.
              - 객체 권한
                  - 데이터베이스 객체의 내용을 조작할 수 있는 권한
                  - 해당 객체의 주인(소유자)가 부여/박탈이 가능하다.
            롤(role)
                  - 사용자에게 부여할 수 있는 권한들의 집합이다.
                  - 여러 개의 권한을 묶어서 하나의 롤을 정의할 수 있다.
                  * 권한의 부여/박탈이 쉬워진다.
                  - 주로 사용되는 롤
                      - Connect Role
                          - 오라클에 접속할 수 있는 세션을 생성할 수 있는 권한
                          - 일반적인 데이터베이스 객체를 생성하거나 조회할 수 있는 권한
                      - Resource Role
                          - PL/SQL을 사용할 수 있는 권한
                          * 일반 사용자에게는 Connect, Resource Role을 부여한다.
                      - DBA Role
                          - 모든 시스템 권한이 부여된 Role이다.
                          - 데이터베이스 관리자에게 부여된다.

0417
set 연산자
    - 두 개 이상의 조회 결과를 하나로 결합한다.
    - 연산자
        - UNION
            A UNION B 1 2 3 4 5 6 7
            A의 조회 결과와 B의 조회 결과에 포함된 모든 행을 반환한다.
            단 A와 B 둘 다에 포함되어 있는 행은 한 번만 선택된다.
            (A와 B의 합집합을 반환한다. 단 중복된 행은 한 번만)
        - UNION ALL
            A UNION ALL B 1 2 3 4 3 4 5 6 7
            A의 조회 결과와 B의 조회 결과에 포함된 모든 행을 반환한다.
            A와 B 모두에 포함된 중복된 행도 모두 반환한다.
            (A와 B의 합집합을 반환한다. 중복된 행 포함)
        - INTERSECT
            A INTERSECT B 3 4
            A의 조회 결과와 B의 조회 결과에 공통으로 포함된 행만 반환한다.
            (A와 B의 교집합을 반환한다.)
        - MINUS
            A MINUS B 1 2
            A의 조회 결과에서 B의 조회 결과를 뺀 행을 반환한다.
            (A와 B의 차집합을 반환한다.)
    - 쿼리 작성 시 주의 사항
        - A 쿼리문과 B 쿼리문의 선택된 컬럼의 개수가 동일해야 한다.
            SELECT 컬럼 1, 컬럼 2
            FROM A
            UNION
            SELECT 컬럼3, 컬럼7
            FROM B
        - A 쿼리문과 B 쿼리문의 선택된 컬럼의 데이터 타입이 동일해야 한다.
        - A 쿼리문과 B 쿼리문에서 선택된 컬럼의 이름은 동일하지 않아도 된다.
        - 정렬을 위한 ORDER BY 절은 맨 마지막 SELECT문에 붙인다.

다중컬럼 서브쿼리
    - 서브쿼리가 두 개 이상의 컬럼을 반환하는 경우 사용된다.
    - SELECT ~
      FROM ~
      WHERE (컬럼1, 컬럼2) IN (SELECT 컬럼1, 컬럼2
                                        FROM ~
                                        WHERE ~ )
      * 컬럼 간의 실제 컬럼명은 다를 수 있다.

스칼라 서브쿼리
    - 하나의 행에서 하나의 값(1행 1열)만 반환하는 서브쿼리다.
    - 오직 하나의 값을 반환하는 서브 쿼리다.
    - 주로 SELECT절에서 사용된다.
    * DECODE 및 CASE의 조건 및 표현식 부분
    * SELECT문의 모든 절에서 사용 가능하다(GROUP BY 절은 제외)
    * UPDATE 문의 SET절

상호연관 서브쿼리
    - SELECT COLUMN1, COLUMN2
                (SELECT COLUMN1
                 FROM TABLE INNER
                 WHERE INNER.COLUMN3 = OUTER.COLUMN3) 
      FROM TABLE OUTER

    - SELECT COLUMN1, COLUMN2, ...
       FROM TABLE OUTER
       WHERE COLUMN3 = (SELECT COLUMN1
                                 FROM INNER
                                 WHERE INNER.COLUMN4 = OUTER.COLUMN4)
    - 상호연관 서브쿼리는 OUTER 쿼리의 행이 조회될 때마다 서브쿼리가 실행된다.

데이터 모델링
    - 정보 시스템을 구축하기 위한 테이블 관점에서의 업무 분석 기법
    - 약속된 표기법으로 표현하는 과정
    - 데이터베이스 구축을 위한 분석/설계 과정

데이터 모델링의 모델 종류
    - 개념적 데이터 모델: 핵심 엔티티를 선정하고, 앤티티간의 관계를 생성한다. 각 앤티티의 애트리뷰트를 선정한다.
    - 논리적 데이터 모델: 구축하려는 정보 시스템에 맞게 기본키, 애트리뷰트를 정확하게 표현하는 것
    - 물리적 데이터 모델: 실제 데이터베이스에 적용할 수 있도록 테이블, 컬럼, 데이터 타입 등을 고려해서 설계한 것

앤티티
    - 업무에 필요한 정보를 저장하는 것
    - 영구적으로 존재하는 데이터인 경우 
    - 누가 봐도 정확하게 구분되는 데이터 집합인 경우
앤티티의 종류
    - Key entity, Main entity, Action entity, Child entity
속성(Attributes)
    - 앤티티가 가지는 특징
    - 앤티티를 구성하는 값
    - 앤티티에서 관리하고자 하는, 더 이상 분리되지 않는 데이터의 최소 단위
관계(Relation)
    - 두 개의 앤티티 사이의 논리적인 관계
    - 관계는 분포도, 존재 유무, 방향으로 구성된다.
    * 관계 = 분포도(O, <) + 존재유무(|) + 방향(─)
브릿지 테이블

0418
계층형 쿼리
    - 테이블에 저장된 데이터가 상위 계층과 하위 계층의 관계를 가지고 있을 때 오라클에서는 start with와 connect by를 이용해서 상위->하위, 하위->상위로 데이터를 조회할 수 있다.
    - 형식
      select level, 컬럼명, 컬럼명, ...
      from table
      where 조건식
      start with 계층의 시작점(시작행)을 지정합니다.
      connect by 검색 방향을 지정
      * connect by prior 부모행의 키 = 자식행의 키 <-- 부모에서 자식으로 트리 구성
      * connect by prior 자식행의 키 = 부모행의 키 <-- 자식에서 부모로 트리 구성
      * level은 계층형 쿼리에서 수행 결과의 depth를 표현하는 의사 컬럼이다.
      - 계층형 쿼리의 실행 순서
      select level, 컬럼명, 컬럼명, ...                           5
      from table                                                   1
      where 조건식                                               4
      start with 계층의 시작점(시작행)을 지정합니다.    2
      connect by 검색 방향                                     3

'Oracle Database SQL' 카테고리의 다른 글

190418  (0) 2019.06.07
190417  (0) 2019.06.07
190416(2)  (0) 2019.06.07
190416  (0) 2019.06.07
190415  (0) 2019.06.07
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../resources/jquery/jquery.min.js"></script>
</head>
<body>
	<div id="page">
		<h1 id="header">목록</h1>
		<h2>구입물품 목록</h2>
		<ul>
			<li id="one" class="hot"><em>따뜻한 </em>라떼</li>
			<li id="two" class="cold">냉동만두</li>
			<li id="three" class="cold">우유</li>
			<li id="four" class="hot">피자</li>
		</ul>
	</div>
	<script type="text/javascript">
		// jQuery 기본 선택자
		
		// 1. 전체 선택자
		//	$("*") : html 문서 내의 모든 엘리먼트를 선택한다.
		$("*").css("color", "lightgreen");
		// 2. 태그 선택자
		//	$("태그명") : html 문서에서 태그명에 해당하는 모든 엘리먼트를 선택한다.
		$("h1").css("color", 'red');
		$("li").css('color', "maroon");
		
		// 3. 아이디 선택자
		// $("#아이디") : html 문서에서 아이디에 해당하는 첫 번째 엘리먼트를 선택한다.
		$('#one').css('background-color', 'lightgrey');
		$('#three').css('background-color', 'orange');
		
		// 4. 클래스 선택자
		// $(".클래스") : html 문서에서 class 속성값이 지정된 클래스를 포함하고 있는 모든 엘리먼트를 선택한다.
		$(".hot").css("border", '2px solid red').css("padding", '10px');
		
		// 5. 다중 선택자
		// $("선택자, 선택자") : html 문서에서 제시된 각각의 선택자에 해당하는 모든 엘리먼트를 선택한다.
		$(".cold, h2").css('border', '2px solid blue');
		
		// 6. 필터링하기
		// $(선택자1선택자2) :선택자1로 선택된 엘리먼트 중에서 선택자2에 해당하는 것만 선택한다.
		$('li.cold')	// li이면서 클래스가 cold인 엘리먼트 선택 --> 2개 선택됨
		$('ul.cold')	// ul이면서 cold인 엘리먼트 선택 --> 선택된 엘리먼트 없음
		
		// $('').css();
		
	
	</script>
</body>
</html>

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery 연습</title>
<script type="text/javascript" src="../resources/jquery/jquery.min.js"></script>
</head>
<body>
	<h1>뉴스</h1>
	
	<div id="breaking-news">
		<h3>속보</h3>
		<ul id="breaking-news-box">
			<li>전세계에 좀비 바이러스 창궐</li>
			<li>주요국 지도자들 지하벙커로 피신</li>
			<li>전 지구적인 교통망, 통신망 회생 불가능 상태로 파괴</li>
		</ul>
	</div>
	
	<div id="news-box">
		<h3>주요 뉴스</h3>
		<div class="box">
			<h3>스포츠 뉴스</h3>
			<ul id="sports-box">
				<li>누구누구 무슨무슨 상 수상</li>
				<li>U-20 월드컵 한국 결승 진출</li>
				<li>누구누구 피파 올해의 선수상 수상</li>
			</ul>
		</div>
		<div class="box">
			<h3>연예 뉴스</h3>
			<ul id="ent-box">
				<li>그룹 누구누구 멤버간 불화로 해체</li>
				<li>누구누구 개인 회생 신청</li>
				<li>누구누구 그래미상 주요 부문 모두 수상</li>
			</ul>
		</div>
	</div>
	
	<div id="movie-box">
		<h3>영화 뉴스</h3>
		<div class="box">
			<h3>개봉영화</h3>
			<ul id="ranking-box">
				<li>1위, 기생충</li>
				<li>2위, 알라딘</li>
				<li>3위, X맨, 다크 피닉스</li>
			</ul>
		</div>
	</div>
	
	<script type="text/javascript">
		// 계층 선택자
		
		// 1. 자손 선택자(하위 선택자)
		// $("선택자1 선택자2") : 선택자1의 하위 엘리먼트 중에서 선택자2에 해당하는 엘리먼트를 선택한다.
		// 속보만 빨갛게 표시하기
		// id="breaking-news-box"인 ul 하위의 li를 선택한다.
		$('#breaking-news-box li').css('color', 'red');
		
		// 주요 뉴스, 스포츠 뉴스, 연예 뉴스 제목을 파랗게 표시하기
		$("#news-box h3").css('color', 'blue');
		
		// 2. 자식 선택자
		// $("선택자1 > 선택자2") : 선택자1의 자식 엘리먼트 중에서 선택자2에 해당하는 엘리먼트를 선택한다.
		// 주요 뉴스 제목만 밑줄 표시하기
		// id="breaking-news-box"의 자식 엘리먼트 h3 찾기
		$('#news-box > h3').css("text-decoration", "underline");
		
		// 3. 동생 선택자(next 선택자)
		// $("선택자1 + 선택자2") : 선택자1의 엘리먼트 바로 다음에 오는 엘리먼트가 선택자2에 해당할 때 선택한다.
		// 주요 뉴스 중에서 스포츠 뉴스 관련 div를 선택해서 테두리 표시하기
		// id="news-box"의 자식 엘리먼트 h3과 인접한 div 찾기
		$("#news-box > h3 + div").css('border', "3px solid red");
		
		// 4. 동생들 선택자
		// $("선택자1 ~ 선택자2") : 선택자1의 동생 엘리먼트들 중에서 선택자2에 해당하는 엘리먼트를 모두 선택한다.
		// $("선택자1 ~ 선택자2") : 선택자1의 동생 엘리먼트들 중에서 선택자2에 해당하는
		// 스포츠 뉴스와 연예 뉴스에만 배경색 넣기
		// id="news-box"인 엘리먼트의 하위 엘리먼트 중에서 div를 찾아서 배경색 넣기
		$("#news-box div").css("background-color", 'yellow');
		// id="news-box"인 엘리먼트의 하위 엘리먼트 중에서 클래스가 box인 엘리먼트를 찾아서 배경색 넣기
		$("#news-box .box").css('background-color', 'yellow');
		// id="news-box"의 자식 엘리먼트 h3의 동생들 중에서 div를 찾아서 배경색 넣기
		$("#news-box > h3 ~ div").css('background-color', 'yellow');
		// id="news-box"의 자식 엘리먼트 h3의 동생들 중에서 클래스가 box인 엘리먼트를 찾아서 배경색 넣기
		$("#news-box > h3 ~ .div").css('background-color', 'yellow');
	</script>
</body>
</html>

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery 연습</title>
<script type="text/javascript" src="../resources/jquery/jquery.min.js"></script>
</head>
<body>
	<h1>뉴스</h1>
	
	<div id="breaking-news">
		<h3>속보</h3>
		<ul id="breaking-news-box">
			<li>전세계에 좀비 바이러스 창궐</li>
			<li>주요국 지도자들 지하벙커로 피신</li>
			<li>전 지구적인 교통망, 통신망 회생 불가능 상태로 파괴</li>
		</ul>
	</div>
	
	<div id="news-box">
		<h3>주요 뉴스</h3>
		<div class="box">
			<h3>스포츠 뉴스</h3>
			<ul id="sports-box">
				<li>누구누구 무슨무슨 상 수상</li>
				<li>U-20 월드컵 한국 결승 진출</li>
				<li>누구누구 피파 올해의 선수상 수상</li>
			</ul>
		</div>
		<div class="box">
			<h3>연예 뉴스</h3>
			<ul id="ent-box">
				<li>어떤 그룹 멤버간 불화로 해체</li>
				<li>누구누구 개인 회생 신청</li>
				<li>누구누구 그래미상 주요 부문 모두 수상</li>
			</ul>
		</div>
	</div>
	
	<div id="movie-box">
		<h3>영화 뉴스</h3>
		<div class="box">
			<h3>개봉영화</h3>
			<ul id="ranking-box">
				<li>1위, 기생충</li>
				<li>2위, 알라딘</li>
				<li>3위, X맨, 다크 피닉스</li>
			</ul>
		</div>
	</div>
	
	<div id="movie-list-box">
		<table id="movie-table" style="border: 1px solid black; width: 100%">
			<thead>
				<tr>
					<th>순위</th>
					<th>제목</th>
					<th>개봉일</th>
					<th>관객수</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>1</td>
					<td>기생충</td>
					<td>6.10</td>
					<td>5,000,000</td>
				</tr>
				<tr>
					<td>2</td>
					<td>알라딘</td>
					<td>6.5</td>
					<td>1,000,000</td>
				</tr>
				<tr>
					<td>3</td>
					<td>다크 피닉스</td>
					<td>5.26</td>
					<td>800,000</td>
				</tr>
				<tr>
					<td>4</td>
					<td>맨인블랙</td>
					<td>6.12</td>
					<td>4,000</td>
				</tr>
				<tr>
					<td>5</td>
					<td>맨인블랙</td>
					<td>6.12</td>
					<td>4,000</td>
				</tr>
				<tr>
					<td>6</td>
					<td>맨인블랙</td>
					<td>6.12</td>
					<td>4,000</td>
				</tr>
				<tr>
					<td>7</td>
					<td>맨인블랙</td>
					<td>6.12</td>
					<td>4,000</td>
				</tr>
				<tr>
					<td>8</td>
					<td>맨인블랙</td>
					<td>6.12</td>
					<td>4,000</td>
				</tr>
			</tbody>		
		</table>
	</div>
	
	<script type="text/javascript">
		// 기본 필터 선택자
		// 1. 첫 번째 요소 선택자
		// $('선택자:first')
		$("li:first").css("color", 'red');
		
		// 2. 마지막 요소 선택자
		// $('선택자:last')
		$("li:last").css('color', 'red');
		
		// 3. 홀수 번째 요소 선택자
		// $('선택자:odd')
		$('li:odd').css('background-color', 'yellow');
		
		// 4. 짝수 번째 요소 선택자
		// $('선택자:even')
		$('li:even').css('background-color', '#ddd');
		
		// 5. 지정된 인덱스번째 요소 선택자
		// $('선택자:eq(인덱스)') *인덱스는 0부터 시작
		$('#sports-box li:first').css('border', '2px solid green');
		$('li:eq(2)').css("font-size", '25px');
		// <li> 2위, 알라딘 </li>을 매진처리하기
		$('#ranking-box li:eq(1)').css('text-decoration', 'line-through');
		
		// 6. 지정된 인덱스번째의 이전 요소들 선택자
		// $('선택자:lt(인덱스)') *인덱스는 0부터 시작
		// 영화순위가 1, 2, 3위 tr를 선택해서 글자를 빨갛게 표시하기
		$('#movie-table tbody tr:lt(3)').css('color', 'red');
		
		// 7. 지정된 인덱스번째의 이후 요소들 선택자
		// $('선택자:gt(인덱스)') *인덱스는 0부터 시작
		// 영화 순위가 4, 5, 6, 7, 8위 tr를 선택해서 글자를 흐리게 표시하기
		$('#movie-table tbody tr:gt(3)').css('color', 'grey');
	</script>
</body>
</html>

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery 연습</title>
<script type="text/javascript" src="../resources/jquery/jquery.min.js"></script>
</head>
<body>
	<h1>사이트 목록</h1>
	
	<div id="sns-box">
		<h3>SNS 사이트</h3>
		<ul>
			<li><a href="https://www.instagram.com" title="사진공유">인스타그램</a></li>
			<li><a href="https://www.facebook.com/" title="일상, 사진공유">페이스북</a></li>
			<li><a href="https://twitter.com" title="소식 공유">트위터</a></li>
			<li><a href="https://www.kakaostory.co.kr" title="한국의 sns">카카오스토리</a></li>
		</ul>
	</div>
	
	<div id="search-site-box">
		<h3>검색 사이트</h3>
		<ul>
			<li><a href="https://www.google.com" title="최대 검색 사이트">구글</a></li>
			<li><a href="https://www.daum.net" title="국내 2위 업체">다음</a></li>
			<li><a href="https://www.naver.com" title="국내 1위 업체">네이버</a></li>
			<li><a href="https://www.yahoo.com" title="일본 최대 검색 사이트">야후</a></li>
		</ul>
	</div>
	
	<h3>새 사이트 등록</h3>
	<form action="">
		<label>사이트 주소</label> <input type="text" name="siteurl"><br />
		<label>사이트 이름</label> <input type="text" name="sitename" id="sitename"><br />
		<label>사이트 종류</label> <input type="checkbox" name="sitetype" id="ck-1"> sns
								<input type="checkbox" name="sitetype" id="ck-2"> 검색
								<input type="checkbox" name="sitetype" id="ck-3"> 커뮤니티
								<input type="checkbox" name="sitetype" id="ck-4"> 웹툰
								<input type="checkbox" name="sitetype" id="ck-5"> 포탈<br />
		<label>사이트 소개</label>  <textarea rows="5" cols="60" name="desc"></textarea><br />
		<button type="submit">등록</button>
	</form>
	
	<script type="text/javascript">
		// 속성 선택자
		// 1. 지정된 속성을 가지고 있는 요소를 선택
		// #('[속성명]')
		// title 속성을 가지고 있는 요소를 선택하기
		$("[title]").css('background-color', 'lightgreen');
		
		// 2. 지정된 속성/속성값이 일치하는 요소를 선택
		// $("[속성명='속성값']")
		// 타입 속성이 text인 것 선택
		$("[type='text']").css('border', '2px dashed red');
		// href 속성이 https://www.daum.net인 것 선택
		$("[href='https://www.daum.net']").css('font-size', '30px');
		// 타입속성이 checkbox인 것 선택
		$("[type='checkbox']").prop("checked", true);
		// name 속성이 sitetype인 것 중에서 첫 번째 것 선택
		$("[name='sitetype']:first").prop("checked", true);
		
		// 3. 속성이 지정된 속성값으로 시작하는 요소를 선택
		// $("[속성명^='속성값']")
		// 검색 사이트 중에서 국내 검색 사이트 검색
		// title의 속성값이 "국내"로 시작하는 것 검색
		$("#search-site-box [title^='국내']").css("border", '2px dashed maroon');
		
		// 4. 속성이 지정된 속성값으로 끝나는 요소를 선택
		// $("[속성명$='속성값']")
		// 링크의 주소값이 'com'으로 끝나는 것 검색
		$("a[href$='com']").css('color', 'white');
		
		// 5. 속성이 지정된 속성값을 포함하고 있는 요소를 선택
		// $("[속성명*='속성값']")
		$("[title*='공유']").css('font-size', '9px');
		
		// 6. 속성이 지정된 속성값을 분리된 단어로 포함하고 있는 요소를 선택
		// $("[속성명~='속성값']")
		$("[title~='공유']").css('padding-right', '200px');
		
	</script>
	
</body>
</html>

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery 연습</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
	<h1>jQuery 연습</h1>
	
	<div class="movie-box">
		<h3>영화 랭킹</h3>
		<table border="1" style="width:100%;">
			<thead>
				<tr>
					<th>순위</th>
					<th>제목</th>
					<th class="number-field">관객수</th>
					<th>개봉일</th>
				</tr>
			</thead>
			<tbody>
				<tr class="top">
					<td>1</td>
					<td>기생충</td>
					<td class="number-field">7,373,743</td>
					<td>2019.05.30</td>
				</tr>
				<tr>
					<td>2</td>
					<td>알라딘</td>
					<td class="number-field">4,113,400</td>
					<td>2019.05.23</td>
				</tr>
				<tr>
					<td>3</td>
					<td>맨 인 블랙</td>
					<td class="number-field">3,140</td>
					<td>2019.06.12</td>
				</tr>
				<tr>
					<td>4</td>
					<td>엑스맨: 다크 피닉스</td>
					<td class="number-field">793,192</td>
					<td>2019.06.05</td>
				</tr>
				<tr>
					<td>5</td>
					<td>이웃집 토토로</td>
					<td class="number-field">110,845</td>
					<td>2001.07.28</td>
				</tr>
			</tbody>
		</table>
	</div>
	
	<div id="movie-detail-box">
		<h3>영화 상세 정보</h3>
		<dl>
			<dt class="movie-title-field">영화제목</dt><dd>이웃집 토토로</dd>
			<dt>영어제목</dt><dd>My Neighbor Totoro</dd>
			<dt class="movie-title-field">평점</dt><dd>9.0</dd>
			<dt class="movie-title-field">쟝르</dt><dd>애니메이션/드라마</dd>
			<dt>제작국가</dt><dd>일본</dd>
			<dt class="movie-title-field">개봉일</dt><dd>2001.07.28</dd>
			<dt>상영시간</dt><dd>80분<span>(1시간 20분)</span></dd>
			<dt>감독</dt><dd><span>미야자키 하야오</span></dd>
		</dl>
	</div>
	
	<div id="movie-form-box">
		<h3>신규 영화 등록</h3>
		<form id="movie-form">
			<p><label>영화제목</label> <input type="text" name="name" /></p>
			<p><label>영어제목</label> <input type="text" name="title" /></p>
			<p><label>영화평점</label> <input type="text" name="point" /></p>
			<p><label>영화장르</label> <input type="checkbox" name="genre" />드라마
									<input type="checkbox" name="genre" />액션
									<input type="checkbox" name="genre" />애니메이션
									<input type="checkbox" name="genre" />스릴러
									<input type="checkbox" name="genre" />공포
									<input type="checkbox" name="genre" />환타지
									<input type="checkbox" name="genre" />SF
									<input type="checkbox" name="genre" />코메디
									<input type="checkbox" name="genre" />뮤지컬
									</p>
			<p><label>제작국가</label> <input type="radio" name="nation" />한국
									<input type="radio" name="nation" />미국
									<input type="radio" name="nation" />일본
									<input type="radio" name="nation" />중국
									<input type="radio" name="nation" />유럽
									<input type="radio" name="nation" />기타
									</p>
			<p><label>개봉일자</label> <input type="date" name="opendate" /></p>
			<p><label>상영시간</label> <input type="number" name="runningtime" /></p>
			<p><label>감독이름</label> <input type="text" name="director" /></p>
			<p><button type="submit">등록</button><button type="reset">취소</button></p>
		</form>
	</div>
	<script type="text/javascript">
		// 1. jQuery 연습의 글자색을 빨갛게 바꾸기
		$("h1").css('color', 'red');
		
		// 2. 영화랭킹, 영화상세정보, 신규영화등록을 파랗게 바꾸기
		$("h3").css('color', 'blue');
		
		// 3. 영화랭킹, 영화상세정보, 신규영화등록 각각의 블록에 테두리를 추가
		$("div").css('border', '1px solid');
		
		// 4. 영화랭킹의 순위, 제목, 관객수, 개봉일의 배경색을 회색으로 바꾸기
		$(".movie-box th").css('background-color', 'grey');
		
		// 5. 영화랭킹에서 순위가 1위인 영화의 정보를 빨갛게 바꾸기
		$(".movie-box .top").css('background-color', 'red');
		
		// 6. 영화 랭킹에서 순위가 1위인 영화제목의 글자 크기를 30px로 설정하기
		$(".movie-box .top td:eq(1)").css('font-size', '30px');
		
		// 7. 영화 랭킹 정보에서 영화 정보 전체를 가운데 정렬하기
		$(".movie-box tbody").css('text-align', 'center');		
		
		// 8. 영화랭킹 정보에서 모든 관객수 컬럼을 오른쪽 정렬하기
		$(".movie-box .number-field").css('text-align', 'right');
		
		// 9. 영화상세 정보에서 제목, 평점, 장르, 개봉일의 글자색을 빨갛게 바꾸기
		$("#movie-detail-box .movie-title-field").css('color', 'red');
		
		// 10. 영화 상세 정보에서 감독 이름을 파랗게 표시하기
		$("#movie-detail-box dd:last span").css('color', 'blue');
		
		// 11. 영화 상세 정보에서 상영 시간을 시간 단위로 표시한 내용만 녹색으로 표시하기
		$("#movie-detail-box dd:eq(6) span").css('color', 'green');
		
		// 12. 신규영화등록에서 각 필드의 명칭(label)을 파랗게 표시하기
		$("#movie-form label").css('color', 'blue');
		
		// 13. 신규영화등록에서 영화제목, 영어제목, 영화평점 입력칸의 테두리만 빨갛게 표시하기
		$("#movie-form [type=text]:lt(3)").css('border', 'red 1px solid');
		
		// 14. 신규영화등록에서 개봉일자 입력칸에 '2019-06-15'를 값으로 설정하기
		$("[name='opendate']").val('2019-06-15');
		
		// 15. 신규영화등록에서 상영시간 입력칸에 "150"을 값으로 설정하기
		$("[name='runningtime']").val('150');
		
		// 16. 신규영화등록에서 감독이름 입력칸에 "홍길동"을 값으로 설정하기
		$("[name='director']").val('홍길동');
		
		// 17. 신규영화등록에서 영화장르체크박스에서 드라마가 체크되어 있게 하기
		$("[name='genre']:first").prop("checked", true);
		
		// 18. 신규영화등록에서 제작국가에 한국이 체크되어 있게 하기
		$("[name='nation']:first").prop("checked", true);
	</script>
</body>
</html>

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery 연습</title>
<script type="text/javascript" src="../resources/jquery/jquery.min.js"></script>
</head>
<body>
	<h1>jQuery 연습</h1>
	
	<div id="singer-box">
		<h3>좋아하는 가수</h3>
		<ul>
			<li>마왕</li>
			<li>악동뮤지션</li>
			<li>신승훈</li>
			<li>에픽하이</li>
		</ul>
	</div>
	
	<div class="fruit-box">
		<h3>좋아하는 과일</h3>
		<ul>
			<li>딸기</li>
			<li>방울토마토</li>
			<li>참외</li>
			<li>수박</li>
			<li>매론</li>
		</ul>
	</div>
	
	<div id="food-box">
		<h3>좋아하는 음식</h3>
		<ul>
			<li>초밥</li>
			<li>닭가슴살</li>
			<li>미역국</li>
			<li>목살</li>
		</ul>
	</div>
	
	<div id="snack-box">
		<h3>좋아하는 과자</h3>
		<ul>
			<li>시장에서 파는 오감자같이 생긴 거</li>
			<li>고구마 말랭이 같이 생긴 거</li>
			<li>동부</li>
			<li>몽쉘</li>
			<li>참깨스틱</li>
			<li>빠다코코넛</li>
			<li>아이비</li>
			<li>맛동산</li>
			<li>김과자</li>
		</ul>
	</div>
	<script type="text/javascript">
		// 자식요소 선택자
		// 1. 부모 요소의 첫 번째 자식을 선택한다.
		// $("선택자:first-child") : 선택자로 선택된 엘리먼트 중에서 부모의 첫 번째 자식인 것만 선택한다.
		// 2. 부모 요소의 마지막 번째 자식을 선택한다.
		// $("선택자:last-child") : 선택자로 선택된 엘리먼트 중에서 부모의 마지막 번째 자식인 것만 선택한다.
		// 3. 부모 요소의 n 번째 자식을 선택한다.
		// $("선택자:nth-child(n)") : 선택자로 선택된 엘리먼트 중에서 부모의 n번째 자식인 것만 선택한다.
		//                          * n은 1부터 시작한다.
		
		// 모든 li 중에서 첫 번째 것 찾기
		$("li:first").css('background-color', 'yellow');
		// 모든 li 중에서 마지막 번째 것 찾기
		$("li:last").css('background-color', 'lightgreen');
		// 모든 li 중에서 2번째 것 찾기
		$("li:eq(1)").css('background-color', 'pink');
		
		// 모든 li 중에서 부모의 첫 번째 자식 찾기
		$("li:first-child").css('font-size', '30px');
		// 모든 li 중에서 부모의 마지막 번째 자식인 것 찾기
		$("li:last-child").css('font-size', '8px');
		// 모든 li 중에서 부모의 2번째 자식인 것 찾기
		$("li:nth-child(2)").css('font-size', '50px');
		
		// 1번째, 4번째, 7번째 과자 선택
		$("#snack-box li:nth-child(3n+1)").css('color', 'red');
	</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery 연습</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
	<h1>jQuery 연습</h1>
	
	<h3>신규 영화 등록</h3>
	<form id="movie-form">
		<p><label>영화제목</label> <input type="text" name="name" /></p>
		<p><label>영어제목</label> <input type="text" name="title" /></p>
		<p><label>트레일러</label> <input type="file" name="video" /></p>
		<p><label>영화평점</label> <input type="text" name="point" /></p>
		<p><label>영화등급</label><select name="grade">
									<option value="0">전체관람가</option>
									<option value="12">12세 이상 관람가</option>
									<option value="15" selected="selected">15세 이상 관람가</option>
									<option value="19">19세 이상 관람가</option>
								</select></p>
		<p><label>영화장르</label> <input type="checkbox" name="genre" />드라마
								<input type="checkbox" name="genre" checked="checked"/>액션
								<input type="checkbox" name="genre" />애니메이션
								<input type="checkbox" name="genre" checked="checked"/>스릴러
								<input type="checkbox" name="genre" checked="checked"/>공포
								<input type="checkbox" name="genre" />환타지
								<input type="checkbox" name="genre" />SF
								<input type="checkbox" name="genre" />코메디
								<input type="checkbox" name="genre" />뮤지컬
								</p>
		<p><label>제작국가</label> <input type="radio" name="nation" />한국
								<input type="radio" name="nation" checked="checked"/>미국
								<input type="radio" name="nation" />일본
								<input type="radio" name="nation" />중국
								<input type="radio" name="nation" />유럽
								<input type="radio" name="nation" />기타
								</p>
		<p><label>개봉일자</label> <input type="date" name="opendate" /></p>
		<p><label>상영시간</label> <input type="number" name="runningtime" /></p>
		<p><label>감독이름</label> <input type="text" name="director" /></p>
		<p><label>영화소개</label> <textarea rows="5" name="summary"></textarea></p>
		<p><button type="submit">등록</button><button type="reset">취소</button></p>
	</form>
	
	<script type="text/javascript">
		// 폼 요소 필터 선택자
		// <form> 태그 내의 input, checkbox, radio, select, textarea 등을 선택할 때 사용한다.
		// 1. $(":input") : 모든 입력요소를 선택한다.
		//                  * input, checkbox, radio, select, textarea를 선택
		
		// 2. $(":text"), $(':password'), $(":radio"), $(":checkbox"), $(":file"), $(":submit"), $(":reset")
		//   : type을 기준으로 대응되는 폼요소를 선택한다.
		// 트레일러 입력필드를 선택해서 비활성화시키기
		$(":file").prop('disbled', true);    // $("[type=file]")
		// 텍스트입력필드 비활성화시키기
		$(":text").prop('disabled', true);    // $("[type=text]")
		
		// 3. $(":selected") : <select>에서 선탠된 옵션을 찾는다.
		// 현재 선택된 영화등급을 선택해서 선택된 값 조회하기
		var grade = $(":selected").text();
		alert(grade);
		
		// 4. $(":checked") : radio, checkbox에서 체크된 것들을 찾는다.
		// 현재 체크된 영화장르를 선택해서 비활성화 시키기
		$(":checkbox:checked").prop('disabled', true);
		
		// 5. $(":enabled"), $(":disabled") : 폼 요소에서 활성화, 비활성화된 것을 찾는다.
		// 비활성화된 요소를 전부 찾아서 활성화시키기
		$(":disabled").prop('disabled', false);
	</script>
</body>
</html>

 

package demo.properties;

import java.io.FileReader;
import java.util.Properties;

public class PropertiesDemo {

	public static void main(String[] args) throws Exception {
		Properties prop = new Properties();

		FileReader reader = new FileReader("src/demo/properties/config.properties");
		
		// void load(Reader reader)
		// FileReader객체를 사용해서 파일의 정보를 읽어온다.
		prop.load(reader);
		
		// String getProperty(String key)
		// 프로퍼티 파일에서 지정된 키값으로 설정된 값을 반환한다.
		String value1 = prop.getProperty("user.name");
		System.out.println(value1);
		
		String value4 = prop.getProperty("select.users");
		System.out.println(value4);
	}
}
package demo.etc;

import java.util.LinkedList;

public class QueueDemo {

	public static void main(String[] args) {
		LinkedList<String> queue = new LinkedList<String>();
		
		queue.offer("홍길동");		
		queue.offer("김유신");		
		queue.offer("강감찬");		
		queue.offer("이순신");
		
		String value1 = queue.poll();
		System.out.println(value1);
		System.out.println("현재 개수 : " + queue.size());
		
		String value2 = queue.poll();
		System.out.println(value2);
		System.out.println("현재 개수 : " + queue.size());

	}
}
package demo.etc;

import java.util.Stack;

public class StackDemo {

	public static void main(String[] args) {
		
		Stack<String> stack = new Stack<String>();
		
		stack.push("홍길동");
		stack.push("김유신");
		stack.push("강감찬");
		stack.push("이순신");
		
		String value1 = stack.pop();
		System.out.println(value1);
		System.out.println("현재 개수 : " + stack.size());
		
		String value2 = stack.pop();
		System.out.println(value2);
		System.out.println("현재 개수 : " + stack.size());

	}
}

'자바 > collection' 카테고리의 다른 글

sort  (0) 2019.06.10
set  (0) 2019.06.10
map  (0) 2019.06.10
list  (0) 2019.06.10
package demo.sort;

import java.util.ArrayList;
import java.util.Collections;

public class ArrayListDemo1 {

	public static void main(String[] args) {
		ArrayList<User> users = new ArrayList<User>();
		users.add(new User(10, "김유신"));
		users.add(new User(80, "이순신"));
		users.add(new User(40, "유관순"));
		users.add(new User(50, "홍길동"));
		users.add(new User(20, "강감찬"));
		
		Collections.sort(users);
		
		for (User user : users) {
			System.out.println(user.getNo() + ", " + user.getName());
		}
	}
}
package demo.sort;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class ArrayListDemo2 {

	public static void main(String[] args) {
		ArrayList<Fruit> box = new ArrayList<Fruit>();
		box.add(new Fruit("사과", 2000));
		box.add(new Fruit("바나나", 6000));
		box.add(new Fruit("오렌지", 3000));
		box.add(new Fruit("아보카도", 8000));
		box.add(new Fruit("토마토", 4000));
		box.add(new Fruit("감", 9000));
		
		Comparator<Fruit> priceComparator = new Comparator<Fruit>() {
			@Override
			public int compare(Fruit o1, Fruit o2) {
				return o1.getPrice() - o2.getPrice();
			}
		};
		
		Collections.sort(box, priceComparator);
		
		for (Fruit fruit : box) {
			System.out.println(fruit.getName() + " " + fruit.getPrice());
		}
	}
}
package demo.sort;

import java.util.TreeSet;

public class TreeSetDemo {

	public static void main(String[] args) {
		TreeSet<User> users = new TreeSet<User>();
		
		users.add(new User(10, "김유신"));
		users.add(new User(80, "이순신"));
		users.add(new User(40, "유관순"));
		users.add(new User(50, "홍길동"));
		users.add(new User(20, "강감찬"));
		
		for (User user : users) {
			System.out.println(user.getNo() + ", " + user.getName());
		}		
	}
}
package demo.sort;

public class User implements Comparable<User>{

	private int no;
	private String name;
	
	public User() {}
	public User(int no, String name) {
		this.no = no;
		this.name = name;
	}

	public int getNo() {
		return no;
	}
	
	public void setNo(int no) {
		this.no = no;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public int compareTo(User o) {
		return name.compareTo(o.name);
	}
    
}
package demo.sort;

public class Fruit {

	private String name;
	private int price;
	
	public Fruit() {}
	public Fruit(String name, int price) {
		this.name = name;
		this.price = price;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public int getPrice() {
		return price;
	}
	
	public void setPrice(int price) {
		this.price = price;
	}
}

'자바 > collection' 카테고리의 다른 글

properties, queue, stack  (0) 2019.06.10
set  (0) 2019.06.10
map  (0) 2019.06.10
list  (0) 2019.06.10
package demo.set;

import java.util.HashSet;
import java.util.Iterator;

public class HashSetDemo1 {

	public static void main(String[] args) {
		HashSet<String> names = new HashSet<String>();
		
		names.add("홍길동");
		names.add("김유신");
		names.add("강감찬");
		names.add("홍길동");
		names.add("이순신");
		names.add("유관순");
		
		Iterator<String> it = names.iterator();
		while (it.hasNext()) {
			String name = it.next();
			System.out.println(name);
		}
		System.out.println();
		names.clear();
		
		System.out.println("비어 있는가? " + names.isEmpty());
		System.out.println("저장된 개수 : " + names.size());
		
		for (String name : names) {
			System.out.println(name);
			
		}
	}
}
package demo.set;

import java.util.HashSet;

public class HashSetDemo2 {

	public static void main(String[] args) {
		
		// Contact에서 hashCode()와 equals() 메소드를 재정의해서
		// 객체가 달라도 번호가 동일하면 동일한 객체로 간주하도록 만들었다.
		
		Contact contact1 = new Contact(10, "홍길동", "010-1111-1111");
		Contact contact2 = new Contact(20, "김유신", "010-2222-1111");
		Contact contact3 = new Contact(10, "홍길동", "010-1111-1111");
		Contact contact4 = new Contact(40, "이순신", "010-4444-1111");
		
		HashSet<Contact> contacts = new HashSet<Contact>();
		contacts.add(contact1);
		contacts.add(contact2);
		contacts.add(contact3);
		contacts.add(contact4);
		contacts.add(contact1);
		contacts.add(contact2);

		System.out.println(contacts);
	}
}
package demo.set;

import java.util.TreeSet;

public class TreeSetDemo {

	public static void main(String[] args) {
		TreeSet<String> names = new TreeSet<String>();
		
		names.add("이순신");
		names.add("김유신");
		names.add("강감찬");
		names.add("홍길동");
		names.add("유관순");
		names.add("김구");
		
		for (String name : names) {
			System.out.println(name);
		}
	}
}
package demo.set;

import java.util.Random;
import java.util.TreeSet;

public class TreeSetDemo2 {

	public static void main(String[] args) {
		TreeSet<Integer> lotto = new TreeSet<Integer>();
		Random random = new Random();
		
		while (true) {
			int number = random.nextInt(45) + 1;
			lotto.add(number);
			
			if (lotto.size() == 6) {
				break;
			}
		}
		System.out.println(lotto);
	}
}
package demo.set;

public class Contact {

	private int no;
	private String name;
	private String tel;
	
	public Contact() {}

	public Contact(int no, String name, String tel) {
		super();
		this.no = no;
		this.name = name;
		this.tel = tel;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	@Override
	public String toString() {
		return "Contact [no=" + no + ", name=" + name + ", tel=" + tel + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + no;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Contact other = (Contact) obj;
		if (no != other.no)
			return false;
		return true;
	}
	
}

'자바 > collection' 카테고리의 다른 글

properties, queue, stack  (0) 2019.06.10
sort  (0) 2019.06.10
map  (0) 2019.06.10
list  (0) 2019.06.10
package demo.map;

import java.util.HashMap;

public class HashMapDemo1 {

	public static void main(String[] args) {
		
		HashMap<Integer, String> map = new HashMap<Integer, String>();
		
		// put(K key, V value)
		// Map객체에 키, 값, 쌍으로 저장하기
		map.put(100, "홍길동");
		map.put(101, "김유신");
		map.put(102, "강감찬");
		map.put(103, "이순신");
		
		// V get(Object key)
		// Map객체에서 지정된 키에 해당하는 값 꺼내기
		String value1 = map.get(101);
		System.out.println(value1);
		
		// V remove(Object key)
		// Map객체에서 지정된 키에 해당하는 값을 반환하고 삭제하기
		map.remove(102);
		
		boolean empty = map.isEmpty();
		System.out.println("비어 있는가? " + empty);
		
		int len = map.size();
		System.out.println("저장된 개수: " + len);
		map.clear();
		System.out.println(map);
	}
}
package demo.map;

import java.util.HashMap;
import java.util.HashSet;

public class HashMapDemo2 {

	public static void main(String[] args) {
		
		HashMap<String, HashSet<String>> map = new HashMap<String, HashSet<String>>();
		
		HashSet<String> team1 = new HashSet<String>();
		team1.add("바다");
		team1.add("유진");
		team1.add("슈");
		
		HashSet<String> team2 = new HashSet<String>();
		team2.add("솔라");
		team2.add("문별");
		team2.add("화사");
		team2.add("휘인");

		HashSet<String> team3 = new HashSet<String>();
		team3.add("웬디");
		team3.add("아이린");
		team3.add("슬기");
		team3.add("조이");
		team3.add("예리");
		
		map.put("SES", team1);
		map.put("마마무", team2);
		map.put("레드벨벳", team3);
		
		HashSet<String> names = map.get("마마무");
		for (String name : names) {
			System.err.println(name);
		}
	}
}

'자바 > collection' 카테고리의 다른 글

properties, queue, stack  (0) 2019.06.10
sort  (0) 2019.06.10
set  (0) 2019.06.10
list  (0) 2019.06.10
package demo.list;

import java.util.ArrayList;

public class ArrayListDemo1 {

	public static void main(String[] args) {
		
		ArrayList<String> names = new ArrayList<String>();
		
		// 객체 저장하기
		// boolean add(E e)
		names.add("홍길동");     //names[0] = "홍길동";
		names.add("김유신");     //names[1] = "김유신";
		names.add("강감찬");     //names[2] = "강감찬";
		names.add("이순신");     //names[3] = "이순신";
		names.add("유관순");     //names[4] = "유관순";
		names.add("유관순");     //names[4] = "유관순";
		names.add("유관순");     //names[4] = "유관순";

		System.out.println(names);
		
		// 지정된 위치의 객체 삭제
		// E remove(int index)
		names.remove(2); // 강감찬 삭제
		
		// 지정된 객체를 삭제
		// boolean remove(Object o)
		names.remove("유관순"); 	// 유관순 삭제
		
		// 지정된 인덱스에 저장된 객체 꺼내기
		// E get(int index)
		String value1 = names.get(0);
		System.out.println("0번째 저장된 객체: " + value1);
		
		
		
		
		// ArrayList에 저장된 모든 객체 꺼내기
		// enhanced for문 사용
		for (String x : names) {
			System.out.println(x);
		}

		// int size()
		// 저장된 객체의 개수를 반환
		int len = names.size();
		System.out.println("저장된 객체의 개수: " + len);
		
		// void clear()
		// 저장된 객체 전체 삭제
		names.clear();
		
		// boolean isEmpty()
		boolean empty = names.isEmpty();
		System.out.println("비어있는가? " + empty);	
	}	
}
package demo.list;

import java.util.ArrayList;

public class ArrayListDemo2 {

	public static void main(String[] args) {
		
		// 기본 자료형을 저장하는 ArrayList
		// 기본 자료형을 저장할 때는 제네릭 타입을 Wrapper 클래스 타입으로 지정한다.
		// int --> Integer, double --> Double, long --> Long, ...
		
		ArrayList<Integer> numbers = new ArrayList<Integer>();
		numbers.add(new Integer(20));
		numbers.add(40); 		// 오토 박싱 --> numbers.add(new Integer(40))
		
		for (Integer x : numbers) {
			System.out.println(x);
		}
		
		for (int x : numbers) {
			System.out.println(x);
		}
		
		ArrayList<Double> scores = new ArrayList<Double>();
	}
}
package demo.list;

import java.util.ArrayList;

public class ArrayListDemo3 {

	public static void main(String[] args) {
		
		// 객체를 저장하는 ArrayList
		ArrayList<Book> books = new ArrayList<Book>();
		
		Book book1 = new Book(100, "이것이 자바다", "신용권", "한빛미디어", 30000);
		Book book2 = new Book(200, "데이터베이스 개론", "홍길동", "한빛미디어", 29000);
		Book book3 = new Book(300, "자바 디자인 패턴", "켄트벡", "인사이트", 32000);
		Book book4 = new Book(400, "인사이트 자바스크립트", "김유신", "한빛미디어", 27000);
		
		books.add(book1);
		books.add(book2);
		books.add(book3);
		books.add(book4);
		books.add(new Book(500, "스프링 3.0", "이일민", "에이콘출판사", 75000));
		
		System.out.println(books);

		int total = 0;
		for (Book book : books) {
			System.out.println("제목 : " + book.getTitle());
			System.out.println("가격 : " + book.getPrice());
		
			total += book.getPrice();
		}
		System.out.println("전체 가격 : " + total);
	}
}
package demo.list;

import java.util.ArrayList;
import java.util.Iterator;

public class ArrayListDemo4 {

	public static void main(String[] args) {
		
		ArrayList<String> names = new ArrayList<String>();
		names.add("홍길동");
		names.add("김유신");
		names.add("강감찬");
		names.add("이순신");
		names.add("이성계");
		names.add("김구");
		names.add("김좌진");
		
		for (String name : names) {
			System.out.println(name);			
		}
        
		System.out.println();
		
		for (int i=0; i<names.size(); i++) {
			String name = names.get(i);
			System.out.println(name);
		}
		System.out.println();
		
		/*
		 * Iterator<E>
		 *        콜렉션(List 및 Set)의 요소를 추출, 삭제할 때 사용되는 객체다.
		 *        주요 메소드
		 *        boolean hasNext()     - 추출할 객체가 남아있으면 true를 반환한다.
		 *        E          next()     - 객체를 하나 꺼내서 반환한다.
		 *        void     remove()     - 객체를 삭제한다.
		 */
		
		Iterator<String> it = names.iterator();
		while (it.hasNext()) {
			String name = it.next();
			System.out.println(name);
			if (name.startsWith("김")) {
				it.remove();
			}
		}
		System.out.println(names);
	}
}
package demo.list;

public class Book {
		
	private int no;
	private String title;
	private String author;
	private String publisher;
	private int price;

	public Book() {}

	public Book(int no, String title, String author, String publisher, int price) {
		super();
		this.no = no;
		this.title = title;
		this.author = author;
		this.publisher = publisher;
		this.price = price;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getPublisher() {
		return publisher;
	}

	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	@Override
	public String toString() {
		return "Book [no=" + no + ", title=" + title + ", author=" + author + ", publisher=" + publisher + ", price="
				+ price + "]";
	}		
}

 

'자바 > collection' 카테고리의 다른 글

properties, queue, stack  (0) 2019.06.10
sort  (0) 2019.06.10
set  (0) 2019.06.10
map  (0) 2019.06.10
package Demo4;

public class Animal {

}
package Demo4;

public class Cat extends Animal {

}
package Demo4;

public class Dog extends Animal {	

}
package Demo4;

public class AnimalApp {

	public static void main(String[] args) {
		Animal a = new Dog();
		Animal b = new Cat();

		Dog c = (Dog) a;
		Cat d = (Cat) b;
		
		Dog e = (Dog) b; // 형 변환 예외 발생
		
	}
}

'자바 > exception' 카테고리의 다른 글

demo3  (0) 2019.06.10
demo2  (0) 2019.06.10
demo1  (0) 2019.06.10
package Demo3;

public class RuntimeExceptionDemo1 {

	public static void stringToUpper(String str) {
		if (str != null) {
			System.out.println(str.toUpperCase());
		}
	}
	
	
	
	public static void main(String[] args) {
		// NullPointException
		// 객체를 참조하지 않는 참조변수(null값을 가지는 참조변수)로
		// 객체의 속성이나 기능을 사용할 때 발생되는 예외다.
		
		String text = null;
		//System.out.println(text.length());
		
		RuntimeExceptionDemo1.stringToUpper(text);
		
	}
}
package Demo3;

public class RuntimeExceptionDemo2 {
	
	public static void main(String[] args) {
		
		// ArrayIndexOutOfBoundException : 배열의 인덱스 범위를 벗어났을 때 발생
		// StringIndexOutOfBoundsException : 문자열의 인덱스범위를 벗어났을 때 발생
		
		String[] names = {"김유신", "강감찬", "이순신"};
		// System.out.println(names[3]);
		
		String text = "abc";
		String subText = text.substring(2, 4);
	}
}
package Demo3;

public class RuntimeExceptionDemo3 {

	public static void main(String[] args) {
		// NumberformatException : 문자열을 숫자로 바꿀 때 숫자로 변환할 수 없는 문자열이 포함되어 있으면 발생
		// int Integer.parseInt(String numberText)
		// double double.parseDouble(String numberText)
		
		String text1 = "1234";
		int number1 = Integer.parseInt(text1);
		System.out.println(number1 * 3);
		
		String text2 = "1234a";
		String text3 = " 1234";
		
		int number2 = Integer.parseInt(text2);
		System.out.println(number2 * 3);
	}
}
package Demo3;

import java.util.Scanner;

public class RuntimeExceptionDemo4 {

	public static void main(String[] args) {
	
		Scanner scanner = new Scanner(System.in);
				
		System.out.println("몸무게 입력> ");
		String value1 = scanner.next();

		System.out.println("키 입력> ");
		String value2 = scanner.next();

		double weight = Double.parseDouble(value1);
		double height = Double.parseDouble(value2)/100;

		double bmi = weight / (height + height);
		System.out.println("bmi 지수 : " + bmi);
		
		if(bmi > 35) {
			System.out.println("고도 비만");
		} else if (bmi > 30) {
			System.out.println("중등도 비만");
		} else if (bmi > 25) {
			System.out.println("경도 비만");
		} else if (bmi > 23) {
			System.out.println("과체중");
		} else if (bmi > 18.5) {
			System.out.println("저체중");
		}
		
		scanner.close();
	}
}
package Demo3;

public class RuntimeExceptionDemo5 {

	public static void main(String[] args) {
		
		String text = "dddd";
		
		int value = StringUtils.stringToInt(text);
		System.out.println("숫자값 : " + value);
	}
}
package Demo3;

public class RuntimeExceptionDemo6 {

	public static void main(String[] args) {
		
		// arithmaic Excpetion 0으로 어떤 수를 나눌 때	}

		System.out.println(3/0);
	}
}
package Demo3;

public class StringUtils {

	public static int stringToInt(String text) {
		int value;
		try {
			value = Integer.parseInt(text);
			
		} catch (NumberFormatException e) {
			value = 0;
		}
		return value;
	}
}

 

'자바 > exception' 카테고리의 다른 글

demo4  (0) 2019.06.10
demo2  (0) 2019.06.10
demo1  (0) 2019.06.10
package Demo2;

import java.io.FileWriter;
import java.io.IOException;

public class ExceptionDemo1 {

	public static void main(String[] args) {
		
		// 예외 정보 얻기, 출력하기
		try {
			FileWriter writer = new FileWriter("c:/sample.txt");
			writer.write("예외정보 얻기");
			writer.flush();
			writer.close();
		} catch (IOException e) {
			System.out.println("예외 발생!");
			String message = e.getMessage();
			System.out.println("예외 정보 : " + message);
			
			String text = e.toString();
			System.out.println("예외 정보 : " + text);
			
			e.printStackTrace();
		}
	}
}
package Demo2;

public class MyexceptionDemo1 {
	/**
	 * 문자열 배열을 전달받아서 화면에 배열의 내용을 출력하는 메소드
	 * @param names 문자열 배열
	 * @throws MyException 배열이 null이거나 배열의 길이가 0인 경우 예외 발생
	 */
	// 사용자정의 일반예외 <-- Exception 클래스를 상속받으면 일반예외가 된다.
	// 일반예외는 예외처리가 필수다.
	public static void printArray(String[] names) throws MyException {
		if (names == null || names.length == 0) {	// 예외 상황
			throw new MyException("null인 배열이 전달되었습니다.");
		}
		for (String item : names) {
			System.out.println(item);
		}
	}
	public static void main(String[] args) {
		
		String[] teamNames = {"영업팀", "서울팀", "경기팀"};
		String[] studentNames = null;
		try {
			MyexceptionDemo1.printArray(teamNames);
			MyexceptionDemo1.printArray(studentNames);

		} catch (MyException e) {
			e.printStackTrace();
		}
	}
}
package Demo2;

public class MyException extends Exception {
	public MyException() {
		
	}
	
	public MyException(String message) {
		super(message); 			// 예외 정보로 저장된다(Exception의 생성자 호출).
		
	}
}
package Demo2;

// 사용자정의 실행예외 <-- RuntimeException을 상속받으면 실행예외가 된다.
// 실행예외는 예외처리가 선택이다.
public class MyRuntimeException extends RuntimeException {

	public MyRuntimeException() {
		
	}
	
	public MyRuntimeException(String message) {
		super(message);
	}
}
package Demo2;

public class MyRuntimeExceptionDemo1 {

	public static void printArray(String[] items) {
		if (items == null || items.length == 0) {
			throw new MyRuntimeException("배열이 null이거나 길이가 0입니다.");
		}
		
		for (String item : items) {
			System.out.println(item);
		}
	}
	
	public static void main(String[] args) {
		String[] teamNames = {"영업팀", "서울팀", "경기팀"};
		String[] studentNames = null;
		
		MyRuntimeExceptionDemo1.printArray(teamNames);
		MyRuntimeExceptionDemo1.printArray(studentNames);
	}
}

'자바 > exception' 카테고리의 다른 글

demo4  (0) 2019.06.10
demo3  (0) 2019.06.10
demo1  (0) 2019.06.10
package Demo1;

import java.io.FileWriter;
import java.io.IOException;

public class ExceptionDemo1 {
	
	public static void main(String[] args) {
		// 일반 예외가 발생하는 경우 예외 처리하기
		try {
		System.out.println("try 블록의 수행문 시작");
		FileWriter writer = new FileWriter("sample.txt");
		writer.write("연습");
		writer.flush();
		writer.close();
		System.out.println("try 블록의 수행문 종료");
		} catch (IOException e) {
			System.out.println("파일 생성 혹은 파일 기록 중 오류가 발생하였습니다.");
			System.out.println(e);
			System.out.println("catch 블록의 수행문");
		
		} finally {
			System.out.println("finally 블록의 수행문");
		}
	}
}
package Demo1;

import java.io.FileWriter;
import java.io.IOException;

public class ExceptionDemo2 {

	public static void main(String[] args) throws IOException {
		
		FileWriter writer = new FileWriter("sample.txt");
		writer.write("연습");
		writer.flush();
		writer.close();
	}
}
package Demo1;

import java.io.FileWriter;
import java.io.IOException;

public class ExceptionDemo3 {

	public static void method1() throws IOException {
		FileWriter writer = new FileWriter("sample.txt");
		writer.write("예외 떠넘기기");
		writer.flush();	
		writer.close();
	}
	public static void method2() throws ClassNotFoundException {
		Class.forName("demo1.ExceptionDemo1");	// demo1.ExcpetionDemo1 설계도를 메모리에 로딩시킨다.
	}
	
	// 메소드1과 2가 처리를 위임한 예외를 다시 떠넘긴다.
	public static void method3() throws IOException, ClassNotFoundException {
		ExceptionDemo3.method1();
		ExceptionDemo3.method2();
	}
	//메소드 1과 2가 처리를 위임한 예외를 try ~ catch로 처리한다.
	public static void method4() {
		try {
			ExceptionDemo3.method1();
			ExceptionDemo3.method2();
			
		}
		catch (IOException e) {
			
		} catch (ClassNotFoundException e) {
			
		}
	}
	
	
	//메소드 1과 2가 처리를 위임한 예외를 try ~ catch로 처리한다.
	public static void method5() {
		try {
			ExceptionDemo3.method1();
			ExceptionDemo3.method2();
			
		}
		catch (IOException | ClassNotFoundException e) {
			
		} 
	}


	
	//메소드 1과 2가 처리를 위임한 예외를 try ~ catch로 처리한다.
	public static void method6() {
		try {
			ExceptionDemo3.method1();
			ExceptionDemo3.method2();
			
		}
		catch (Exception e) {	// Exception 타입의 변수로 선언하면 try블록에서 발생되는 모든 예외를
								// 캐치할 수 있다.				
		} 
	}

	public static void method7() {
		try {
			ExceptionDemo3.method1();
			ExceptionDemo3.method2();
			
			
		} catch (ClassNotFoundException e) {
			
		} catch (IOException e) {
		} catch (Exception e) {
		}	// 마지막 catch에서는 Exception 타입의 변수로 선언함으로써 미처 예상하지 못했던 예외도 캐치를 할 수 있도록 한다.
	}

	
	public static void main(String[] args) {
		
	}
}
package Demo1;

import java.io.FileWriter;
import java.io.IOException;

public class exceptionDemo4 {
	public static void method1() {
		 try {
			 FileWriter writer = new FileWriter("sample.txt");
			 writer.write("예외바꾸기");
			 writer.flush();
			 writer.close();
			 
		 } catch (IOException e) {
			 
		 }
	}
	
	public static void method2() {
		
	}
	
	public static void main(String[] args) {
		
	}
}
package Demo1;

import java.io.FileWriter;
import java.io.IOException;

public class HTAException extends Exception {
	public static void method1() throws HTAException {
		try {
			FileWriter writer = new FileWriter("sample.txt");
			writer.write("예외바꾸기");
			writer.flush();
			writer.close();
		} catch (IOException e) {
			throw new HTAException();	// throw 예외 발생 시키기
		}
	}
	public static void method2() throws HTAException {	// 3. 2번에서 발생시킨 예외를 떠넘긴다.
		try {
			Class.forName("demo1.HTAException");
			
		} catch (ClassNotFoundException e) {	// 1. try 블록에서 발생한 예외를 캐치
			throw new HTAException();			// 2. HTAException 예외를 생성해서 발생시킴
		}
	}
	
	public static void main(String[] args) {
		try {
			method1();
			method2();
		} catch (HTAException e) {	// 4. 처리를 위임받는 예외의 종류가 HTAException 으로 줄어들게 된다.
		}
	}
}

 

'자바 > exception' 카테고리의 다른 글

demo4  (0) 2019.06.10
demo3  (0) 2019.06.10
demo2  (0) 2019.06.10
package Demo5;

public class MathDemo {

	public static void main(String[] args) {
		
		double result1 = Math.ceil(3.1);
		double result2 = Math.ceil(3.0);
		double result3 = Math.ceil(3.9);
		System.out.println(result1);
		System.out.println(result2);
		System.out.println(result3);
		
		double result4 = Math.floor(3.1);
		double result5 = Math.floor(3.0);
		double result6 = Math.floor(3.9);
		System.out.println(result4);
		System.out.println(result5);
		System.out.println(result6);
		
		double result7 = Math.round(3.1);
		double result8 = Math.round(3.0);
		double result9 = Math.round(3.9);
		System.out.println(result7);
		System.out.println(result8);
		System.out.println(result9);
		
	}
}
package Demo4;

import java.util.Date;

public class DateDemo {

	public static void main(String[] args) {
		// 컴퓨터 현재 날짜 및 시간 정보를 갖고 있는 Date객체가 생성된다.
		Date now = new Date();
		java.sql.Date x = null;
		
		System.out.println(now);
		System.out.println(now.toString()); // 날짜와 시간정보를 문자열로 제공하도록 재정의
		
		long value = now.getTime(); // UNIX타임
		System.out.println(value);
		
		now.setTime(1234567890123L);
		System.out.println(now);
		
	}
}
package Demo4;

import java.util.Random;

public class RandomeDemo {
	public static void main(String[] args) {
	
		// 난수를 발생시키는 Random객체 생성
		Random random = new Random();
		
		// int범위의 최솟값과 최댓값 사이의 임의의 정수를 제공
		int num1 = random.nextInt();
		System.out.println(num1);
		
		// 0 <= 난수 < 100
		int num2 = random.nextInt(100);
		System.out.println(num2);

		int num3 = random.nextInt(6) + 1;
		System.out.println(num3);
	}
}
package Demo4;

import java.util.Arrays;

public class ArraysDemo {
	public static void main(String[] args) {
		
		int[] scores = {10, 30, 1, 7, 31, 46, 5};
		Arrays.sort(scores);
		
		System.out.println(Arrays.toString(scores));
		
		String[] names = {"홍길동", "이순신", "강감찬", "김유신", "유관순", "김구"};
		Arrays.parallelSort(names);
		System.out.println(Arrays.toString(names));
	}
}
package Demo4;

public class StringBuilderDemo {

	public static void main(String[] args) {
		
		String title = "이것이 자바다";
		String writer = "신용권";
		int price = 30000;
		
		String text = "제목 : " + title + ", 저자 : " + writer + ", 가격 : " + price;
		System.out.println(text);
		StringBuilder sb = new StringBuilder();
		
		sb.append("제목 : ");
		sb.append(title);
		sb.append(", 저자 : ");
		sb.append(writer);
		sb.append(", 가격 : ");
		sb.append(price);
		
		String text2 = sb.toString();
		System.out.println(text2);
	}
}
package Demo4;

import java.util.StringTokenizer;
public class StringTokenizerDemo {
	public static void main(String[] args) {
		StringTokenizer st = new StringTokenizer("김유신 강감찬 이순신 홍길동");
		
		int count = st.countTokens();
		System.out.println("토큰 개수 : " + count);
		
		boolean b1 = st.hasMoreTokens();
		System.out.println("토큰이 남아 있나? " + b1);

		String name1 = st.nextToken();
		System.out.println(name1);
		
		while (st.hasMoreElements()) {
			String name = st.nextToken();
			System.out.println(name);
			
		}
		
		StringTokenizer st2 = new StringTokenizer("100,20,50,28,59,9,17,83", ",");
		int total = 0;
		
		while (st2.hasMoreElements()) {
			int a = Integer.parseInt(st2.nextToken());
			System.out.println(a);
			total+=a;
		}
		
		System.out.println("합계 : " + total);
		
		String text = "홍길동,010-1111-1111,,중앙HTA";
		String[] values = text.split(",");
		StringTokenizer st3 = new StringTokenizer(text,",");
		
		System.out.println("배열의 길이 : " + values.length);
		System.out.println("토큰의 길이 : " + st3.countTokens());		
	}
}
package Demo4;

public class SystemDemo {
public static void main(String[] args) {
	
	long time = System.currentTimeMillis();
	System.out.println(time);
	
	String value1 = System.getProperty("java.version");
	String value2 = System.getProperty("os.name");
	String value3 = System.getProperty("user.name");
	String value4 = System.getProperty("user.home");
	System.out.println("자바버전 : " + value1);
	System.out.println("운영체제이름: " + value2);
	System.out.println("사용자 이름 : " + value3);
	System.out.println("사용자 홈 디렉토리 : " + value4);
	}
}
package Demo4;
import java.util.Properties;
import java.util.Set;

public class SystemDemo2 {
	public static void main(String[] args) {
		Properties prop = System.getProperties();
		// 시스템의 현재 시간 정보 조회하기
		long time = System.currentTimeMillis();
		System.out.println(time);
		
		// 시스템의 속성값 조회하기
		// String System.getProperty(String name)
		Set<Object> keys = prop.keySet();
		for (Object key : keys) {
			String value = prop.getProperty(key.toString());
			System.out.println("[" + key + "]" + value);
		}
		
		// 시스템의 환경변수값 조회
		// String System.getenv(String name)
		String env1 = System.getenv("JAVA_HOME");
		String env2 = System.getenv("Path");
		System.out.println("자바홈: " + env1);
		System.out.println("패스: " + env2);
		
	}
}
package Demo4;

import java.util.Arrays;

public class SystemDemo3 {
	public static void main(String[] args) {
		
		// 배열 복사
		// void System.arraycopy(Object src, int srcPost, Object dest, int destPos, int length)
		// src : 원본배열
		// srcPso : 원본배열의 복사 시작 위치
		// dest : 목적지 배열
		// destPos : 목적지 배열의 데이터 삽입 시작 위치
		// length : 복사할 배열의 아이템 개수
		String[] src = {"사과", "배", "바나나", "토마토", "레몬", "감", "포도", "오렌지", "멜론"};
		String[] dest1 = new String[5];
		String[] dest2 = new String[10];
		
		System.arraycopy(src, 3, dest1, 0, 5);
		System.arraycopy(src, 0, dest2, 4, 6);
		
		System.out.println(Arrays.deepToString(dest1));
		System.out.println(Arrays.deepToString(dest2));
		
	}
}
package Demo4;

public class WrapperDemo1 {

	public static void main(String[] args) {
		Integer num1 = new Integer(30);   // 박싱
		Integer num2 = new Integer("30");
		
		// 정수값 획득 : int intValue()
		int value1 = num1.intValue();    // 언박싱
		int value2 = num2.intValue();
		System.out.println(value1);
		System.out.println(value2);

		
		Double num3 = new Double(3.14);   // 박싱
		Double num4 = new Double("3.14");
		
		
		// 실수값 획득 : double doubleValue()
		double value3 = num3.doubleValue();    //언박싱
		double value4 = num4.doubleValue();
		System.out.println(value3);
		System.out.println(value4);
		
	}
}
package Demo4;

public class WrapperDemo2 {
	public static void main(String[] args) {
		
		// 오토박싱/언박싱
		Integer num1 = 10; 
		Double num2 = 3.14;
	}
}

'자바 > api' 카테고리의 다른 글

demo3  (0) 2019.06.10
demo2  (0) 2019.06.10
demo1  (0) 2019.06.10
package demo3;

public class StringDemo1 {
	public static void main(String[] args) {
		
		String str1 = "hello world";
		// String str1 = new String("hello world");
		
		// String toUpperCase() : 소문자를 대문자로 변환해서 반환한다.
		// String toLowerCase() : 대문자를 소문자로 변환해서 반환한다.

		String result1 = str1.toUpperCase();
		
		System.out.println("원본1 : " + str1);
		System.out.println("결과1 : " + result1);
		System.out.println("결과1 : " + str1.toUpperCase());
		
		String result2 = result1.toLowerCase();
		System.out.println("결과2 : " + result2);
		System.out.println(str1);

		str1 = str1 + "a";
		System.out.println(str1);

		
		// String replace(String old, String new) : 해당 글자 모두 바꾸기
		String str2 = "이것이 자바다. 자바 초급자를 위한 안내서";
		String result3 = str2.replace("자바", "파이썬");
		System.out.println("원본2 : " + str2);
		System.out.println("결과3 : " + result3);
		
		// int length() : 문자열의 길이를 반환한다.
		String str3 = "오늘 점심은 어떤거 먹지?";
		int len = str3.length();
		System.out.println("문자열의 길이 : " + len);
		
		
		
		String name1 = new String("이순신");
		String name2 = new String("이순신");
		String name3 = "이순신";
		String name4 = "이순신";
		
		System.out.println(name1 == name2);
		System.out.println(name1.equals(name2));
		System.out.println(name3 == name4);
		System.out.println(name3.equals(name4));		

		// 1. == 주소값 비교
		// 2. equals() 내용 비교
		// equals메소드는 String객체를 생성하는 방법에 상관업이 문자열의 내용이 동일하면
		// true값을 반환. 따라서 문자열의 비교는 반드시 equals()메소드를 사용해야 한다.
	
		
		// String substring(int beginIndex): 끝까지 잘라낸 새로운 문자열을 반환
		//String substring(int beginIndex, int endIndex): ~까지 잘라낸 새로운 문자열을 반환
		String str4 = "이것이 자바다";
		String result5 = str4.substring(1);
		System.out.println("결과5: " + result5);
		
		String result6 = str4.substring(2,6);
		System.out.println("결과6: " + result6);
		
		String str5 = "이것이 자바다";
		boolean result7 = str5.contains("자바");
		System.out.println("결과: "+ result7);
		
		// boolean startsWith(String str) : 지정된 문자열로 시작하는지 여부를 반환한다.
		// boolean endsWith(String str) : 지정된 문자열로 끝나는지 여부를 반환한다.
		String str6 = "http://www.daum.net";
		String str7 = "www.google.com";
		String str8 = "www.naver.com";
		System.out.println("결과8: " + str6.startsWith("http"));
		System.out.println("결과9: " + str6.startsWith("http"));
		System.out.println("결과10: " + str6.startsWith("http"));
		System.out.println("결과11: " + str6.startsWith("com"));
		System.out.println("결과12: " + str6.startsWith("com"));
		System.out.println("결과13: " + str6.startsWith("com"));
		
		// boolean empty(): 문자열이 비어있으면 true를 반환.
		
		String str12 = "     이것이 자바다        ";
		String result17 = str12.trim();
		String str11 = "";
		System.out.println("결과17: " + "[" + result17 + "]");
			
		String str13 = "이것이 자바다. 자바 업무용 추천 도서";
		int result18 = str13.indexOf("자바");
		int result19 = str13.indexOf("파이썬");
		System.out.println("결과18 : " + result18);
		System.out.println("결과19 : " + result19);

		String str14 = "이것이 자바다";
		char result20 = str14.charAt(1);
		System.out.println("결과20: " + result20);

		String str15 = " 이순신, 김유신, 강감찬, 홍길동, 유관순";
		String[] result21 = str15.split(",");
		System.out.println("결과21: " + result21[0]);
		System.out.println("결과21: " + result21[1]);
		System.out.println("결과21: " + result21[2]);
		System.out.println("결과21: " + result21[3]);
		System.out.println("결과21: " + result21[4]);	
	}
}
package demo3;

import java.util.Scanner;

public class StringDemo2 {
public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
	
	System.out.print("비밀번호를 입력하세요: ");
	String pwd1 = scanner.next();
	System.out.print("비밀번호를 다시 입력하세요: ");
	String pwd2 = scanner.next();
	
	System.out.println(pwd1 ==pwd2);
	System.out.println(pwd1.contentEquals(pwd2));
	
	// scanner.close();
	}
}
package demo3;

import java.util.Scanner;

public class StringDemo3 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("이메일을 입력하세요: ");
		String email = scanner.next();
		
		int endIndex = email.indexOf("@");
		String id = email.substring(0, endIndex);
		System.out.println("아이디: " + id);
		
		scanner.close();
		}
}
package demo3;

import java.util.Scanner;

public class StringDemo4 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		System.out.println("이름,국어,영어,수학 정보 입력> ");
		String text = sc.next();	// ex. 홍길동,60,80,50
		
		String[] values = text.split(",");
		System.out.println("이름: " + values[0]);
		System.out.println("국어: " + values[1]);
		System.out.println("영어: " + values[2]);
		System.out.println("수학: " + values[3]);
		
		sc.close();
	}
}
package demo3;

public class StringDemo5 {

	public static void main(String[] args) {
		
		String str = "이것이 자바다";
		System.out.println(str.length());
		
		System.out.println("이것이 자바다".length());
		
		String str2 = "       this is a java           ".trim().toUpperCase().substring(0, 5);
		System.out.println(str2);
	}
}

'자바 > api' 카테고리의 다른 글

demo4  (0) 2019.06.10
demo2  (0) 2019.06.10
demo1  (0) 2019.06.10
package demo2;

public class Contact {
	private int no;
	private String name;
	private String tel;
	private String email;

	public Contact() {}

	public Contact(int no, String name, String tel, String email) {
		super();
		this.no = no;
		this.name = name;
		this.tel = tel;
		this.email = email;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	// 오브젝트의 toString[] 메소드 재정의

	@Override
	public String toString() {
		return "Contact [no=" + no + ", name=" + name + ", tel=" + tel + ", email=" + email + "]";
	}
	
	public Contact copyContact() throws CloneNotSupportedException {
		Object obj = clone();
		Contact c = (Contact)obj;
		return c;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + no;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Contact other = (Contact) obj;
		if (no != other.no)
			return false;
		return true;
	}
}
package demo2;

public class ContactApp {

	public static void main(String[] args) {
		
		Contact c = new Contact(10, "김유신", "010-1111-1111", "kim@naver.com");
		Contact cc = new Contact(10, "김유신", "010-1111-1111", "kim@naver.com");
		
		//int hashcode() : 객체에 부여된 일련번호를 점수로 제공하는 메소드
		int hash = c.hashCode();
		int hash2 = cc.hashCode();
		System.out.println("해쉬코드 값 : " + hash);
		System.out.println("해쉬코드 값 : " + hash2);
		
		// String toString() : 객체의 정보를 문자열로 제공하는 메소드
		//					   설계도의 이름 + "@" + 해시코드값(16진수)
		//					   toString()메소드는 재정의해서 필드에 저장된 값들을 문자열로 이어서 제공하도록
		//					   재정의해서 사용한다.
		String info = c.toString();
		String info2 = cc.toString();
		System.out.println("객체의 정보 : " + info);
		System.out.println("객체의 정보 : " + info2);
		//System.out.println(c);
		//System.out.println(cc);
		//System.out.println(c.toString());
		//System.out.println(cc.toString());	
		
		// boolean equals(Object other) : - 전달받은 다른 객체와 이 객체가 동일한 객체인지 여부를 반환한다.
		boolean res1 = c.equals(cc);
		boolean res2 = cc.equals(c);
		System.out.println(res1);
		System.out.println(res2);
		// 같은 곳을 바라볼 때만(=동일한 객체일 때만) true
	}
}
package demo2;

public class ContactCloneApp {

	public static void main(String[] args) throws Exception {
		
		Contact src = new Contact(100, "홍길동", "010-1111-1111", "hong@gmail.com");
	
		Contact cloneContact = src.copyContact();
		System.out.println(cloneContact.getNo());
		System.out.println(cloneContact.getName());
		System.out.println(cloneContact.getTel());
		System.out.println(cloneContact.getEmail());
	}
}
package demo2;

import java.lang.reflect.Method;

import org.omg.CORBA.Context;

public class ContactReflect {
	public static void main(String[] args) throws Exception {
		Contact c = new Contact(10, "홍길동", "010-1111-2222", "hong@hanmail.com");
				
		Class<?> clazz = c.getClass();
		Method[] methods = clazz.getMethods();
		
		for (Method m : methods) {
			System.out.println(m.getName());
			
		}
	}
}

'자바 > api' 카테고리의 다른 글

demo4  (0) 2019.06.10
demo3  (0) 2019.06.10
demo1  (0) 2019.06.10
package demo1;
/**
 * 덧셈, 뺄셈 기능이 구현된 클래스입니다.
 * @author JHTA
 *
 */
public class Calculator {
	/**
	 * 두 수를 전달받아서 더한 값을 반환합니다.
	 * @param x 숫자
	 * @param y 숫자
	 * @return 덧셈 결과가 반환됨
	 */
	public int plus(int x, int y) {
		int z = x + y;
		return z;
	}
	/**
	 * 두 수를 전달받아서 뺀 값을 반환합니다.
	 * @param x 숫자
	 * @param y 숫자
	 * @return 뺄셈 결과가 반환됨
	 */
	public int minus(int x, int y) {
		int z = x - y;
		return z;
	}
}
package demo1;

public class Hello {

	public static void main(String[] args) {
		System.out.println("안녕, 이클립스");
		
		Calculator cal = new Calculator();
	}
}

'자바 > api' 카테고리의 다른 글

demo4  (0) 2019.06.10
demo3  (0) 2019.06.10
demo2  (0) 2019.06.10

+ Recent posts