<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>jin_0.log</title>
        <link>https://velog.io/</link>
        <description>개발자로 가는 길 🏃‍♀️</description>
        <lastBuildDate>Tue, 09 May 2023 03:02:59 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <copyright>Copyright (C) 2019. jin_0.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/jin_0" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 22일차: 정보은닉, 캡슐화, RDBMS(오라클)]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-22%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-22%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Tue, 09 May 2023 03:02:59 GMT</pubDate>
            <description><![CDATA[<h3 id="✅-정보은닉information-hiding-캡슐화encapsulation">✅ 정보은닉(information hiding), 캡슐화(Encapsulation)</h3>
<blockquote>
<ul>
<li>정보은닉: private으로 정보은닉하면 외부에서 읽을 수 없다</li>
<li>정보은닉의 단계: private → default → protected → public</li>
</ul>
</blockquote>
<blockquote>
<ul>
<li>캡슐화: 정보은닉된 클래스를 set, get메서드를 통하여 외부에서 읽고 쓸 수 있게 된다.</li>
<li>마우스 오른쪽 클릭 → source → Generate getter and setter... 를 통해 자동으로 소스를 생성할 수 있다.</li>
</ul>
</blockquote>
<h4 id="✅필드캡슐화">✅필드캡슐화</h4>
<pre><code class="language-java">package vo;

public class Data {
    public int x; 
    private int y;
}</code></pre>
<pre><code class="language-java">package vo;

public class Data2 {
    public int x; 
    private int y;
}</code></pre>
<pre><code class="language-java">    // 필드가 정보은닉이 안된 Data클래스 (x,y는 public이므로 외부에서 읽기, 쓰기 가능)
    Data d = new Data();
    d.x = 7;
    d.y = 10;
    System.out.println(d.x); 
    System.out.println(d.y);

    Data2 d2 = new Data2();
    d2.x = 7; 
    // d2.y = 10; // Data2클래스의 y 필드는 private으로 정보은닉 되어있다 (즉, d2.y는 읽기, 쓰기 불가능)
    System.out.println(d2.x); 
    // System.out.println(d2.y);</code></pre>
<pre><code class="language-java">package vo;
// 필드(속성)정보은닉 + 필드캡슐화
public class Data3 {
    private int x; // 정보은닉
    private int y; // 정보은닉

    public int getX() { // getX를 호출하면 읽기 가능 -&gt; 읽기 캡슐화 메서드
        return this.x;
    }
    public int getY() { // getY를 호출하면 읽기 가능 -&gt; 읽기 캡슐화 메서드
        return this.y;
    }

    public void setX(int x) { // getX를 호출하면 쓰기 가능 -&gt; 쓰기 캡슐화 메서드
        /*
        if(x&lt;0) { // 입력값은 양수만 가능하게 함
            return;
        }
        */
        this.x = x;
    } // int값 x를 입력받아서 this.x에 저장하고, 반환값은 없으므로 void
    public void setY(int y) { // getX를 호출하면 쓰기 가능 -&gt; 쓰기 캡슐화 메서드
        this.y = y;
    } // int값 y를 입력받아서 this.y에 저장하고, 반환값은 없으므로 void

    // static메서드는 클래스이름.메서드로 쓰기 때문에 this를 쓸수 없다
}</code></pre>
<pre><code class="language-java">    Data3 d1 = new Data3();
    Data3 d2 = new Data3();

    d1.setX(777);
    d2.setX(444);

    System.out.println(d1.getX()); // getX의 this -&gt; d1 -&gt; 반환값 777
    System.out.println(d2.getX()); // getX의 this -&gt; d2 -&gt; 반환값 444</code></pre>
<h4 id="✅메서드-캡슐화">✅메서드 캡슐화</h4>
<pre><code class="language-java">package vo;
// 메서드 캡슐화
public class A {
    private String getFirstName() { // 메서드 정보은닉
        return &quot;구디&quot;;
    }
    private String getSecondName() {
        return &quot;아카데미&quot;;
    }
    public String getFullName() {
        return this.getFirstName()+this.getSecondName();
    }

    /*
    public static void main(String[] args) {
        A a = new A();
        String name = a.getFullName();
        System.out.println(name);
    }
    */
}</code></pre>
<pre><code class="language-java">    A a = new A();
    String name = a.getFullName();
    System.out.println(name);

    // 메서드가 private으로 정보은닉되어 있어 읽고 쓸 수 없다.
    // String fname = a.getFirstName();
    // System.out.println(fname);</code></pre>
<h4 id="✅캡슐화의-장점">✅캡슐화의 장점</h4>
<p>캡슐화를 하면 메서드에서 데이터값의 범위를 정할 수 있다.</p>
<pre><code class="language-java">package vo;

import java.util.Calendar;

public class Person {
    private int birth; //필드 은닉
    /*
    private int getBirth() { //getter(메서드) 은닉 -&gt; 사용하지 않으므로 삭제해도 무방
        return birth;
    }
    */

    public void setBirth(int birth) {
        if(birth&gt;0) { // birth는 0보다 큰 값만 저장 가능
            this.birth = birth;
        }
    }

    public int getAge() {
        if(this.birth &gt; 0) { //birth가 0보다 클 때에만 age출력
            Calendar c = Calendar.getInstance();
            int y = c.get(Calendar.YEAR);

            return y-this.birth;
        }
        return 0; // 아닌 경우는 0 출력
    }
}</code></pre>
<pre><code class="language-java">    Person 루피 = new Person();
    루피.setBirth(1995);
    // System.out.println(루피.getBirth()); // getBirth은닉되어 있어 출력할 수 없다
    System.out.println(루피.getAge());</code></pre>
<h3 id="✅rdbms">✅RDBMS</h3>
<h5 id="데이터베이스-논리적-단위행들로-이루어진-관련-정보의-집합">데이터베이스: 논리적 단위(행)들로 이루어진 관련 정보의 집합</h5>
<ol>
<li>행의 수가 많으면 원하는 정보를 찾는데 오래 걸린다.</li>
<li>index가 되어있다면 조회속도는 빨라지나 입력,출력 속도는 느려진다.
(마리아DB는 primary key, foreign key에 인덱스, 오라클은 primary key에만 인덱스)</li>
<li>출력된 이후에는 데이터를 추가하거나 기존의 데이터의 수정/삭제가 어렵다.</li>
</ol>
<h5 id="관계형-모델-데이터를-테이블의-집합으로-표현">관계형 모델: 데이터를 테이블의 집합으로 표현</h5>
<ol>
<li>포인트를 사용하여 관련 Entity(행)을 조회하는 대신, 중복데이터를 사용하여 서로 다른 테이블의 레코드를 연결</li>
<li>이상현상(삽입이상, 갱신이상, 삭제이상)을 예방하기 위하여 정규화
(출처: <a href="https://cafe.naver.com/jjdev">https://cafe.naver.com/jjdev</a>)</li>
</ol>
<hr>
<h3 id="⌨️페이징pagination응용">⌨️페이징(Pagination)응용</h3>
<p>구글링을 통해 직접 방법을 찾아 이전, 현재, 다음이 아닌 페이지 블럭을 설정하여 페이징을 구현하였다.
(출처: <a href="https://beaniejoy.tistory.com/26?category=981157">https://beaniejoy.tistory.com/26?category=981157</a>)</p>
<hr>
<h3 id="💪느낀점">💪느낀점</h3>
<p>처음에는 정말 직접 찾아서 할 수 있을까 걱정했는데 여러 방법들을 읽고 찾아보면서 지금까지 배우고 연습한 내용으로도 충분히 이해가 가능했다. 앞으로도 시간이 있을 때마다 원하는 기능들을 찾아서 적용해봐야겠다. </p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 21일차: SQL JOIN문]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-21%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-21%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Fri, 05 May 2023 02:10:44 GMT</pubDate>
            <description><![CDATA[<h3 id="✅sql-join문">✅SQL JOIN문</h3>
<p>UNION ALL이 두 테이블의 행을 합치는 것이었다면 JOIN문은 두 테이블의 열을 합치는 것이다.</p>
<pre><code class="language-sql">SELECT board_no, board_title
FROM board
WHERE board_no = 1000;

SELECT comment_no, board_no, comment_content
FROM comments
WHERE board_no = 1000;

SELECT b.board_title, b.board_no, c.board_no, c.comment_content
FROM board b INNER JOIN comments c
ON b.board_no = c.board_no
WHERE b.board_no = 1000
ORDER BY c.createdate DESC;
-- JOIN문의 조건은 ON으로 나타낸다</code></pre>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>오늘 JOIN문을 배웠지만 실제 과제에서는 JOIN문을 사용하지 않았다. 
하지만 요구사항에 따라 JOIN문을 사용해야하는 경우가 있기 때문에 꼭 익혀놓자.</li>
<li>❗유효성 검사가 끝난 후 변수에 요청값을 저장하고 나면 vo타입으로 묶는다</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 20일차: HashMap, SQL GROUP BY절]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-20%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-20%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Fri, 05 May 2023 02:03:12 GMT</pubDate>
            <description><![CDATA[<h3 id="✅외래키foreign-key">✅외래키(Foreign Key)</h3>
<p>다른 테이블의 기본키를 참조하는 키이다.</p>
<h3 id="✅hashmap">✅HashMap</h3>
<ul>
<li>VO타입(클래스) 대신 HashMap&lt;키 타입, 값 타입&gt;에 조회한 데이터를 저장한다</li>
<li>HashMap은 테이블에 없는 컬럼(count등)을 출력할 때 사용한다</li>
</ul>
<pre><code class="language-java">    // VO타입대신 HashMap타입을 사용

    HashMap&lt;String, Object&gt; map = null; 
    // map이라는 이름을 가진 키(String), 값(Object)의 HashMap타입 변수 -&gt; Object에는 모든 타입이 들어올 수 있다
    // rs.next()가 &#39;참&#39;일때만 map을 만들면 되기 때문에 초기값은 null
    if(rs.next()){
        // System.out.println(rs.getString(&quot;localName&quot;));
        // System.out.println(rs.getString(&quot;country&quot;));
        // System.out.println(rs.getString(&quot;worker&quot;));
        map = new HashMap&lt;String, Object&gt; ();
        map.put(&quot;localName&quot;, rs.getString(&quot;localName&quot;)); // map.put(키이름, 값)
        map.put(&quot;country&quot;, rs.getString(&quot;country&quot;));
        map.put(&quot;worker&quot;, rs.getString(&quot;worker&quot;));
    } // 한 행의 HashMap을 만들고 rs의 값을 넣는다
    System.out.println((String)map.get(&quot;localName&quot;)); // rs.getString(&quot;localName&quot;)(Object타입)이 String으로 형변환되어 출력된다 

    PreparedStatement stmt2 = null;
    ResultSet rs2 = null;
    // 테이블에 없는 country, worker컬럼 출력
    String sql2 = &quot;SELECT local_name localName, &#39;대한민국&#39; country, &#39;admin&#39; worker FROM local&quot;;
    stmt2 = conn.prepareStatement(sql2);
    System.out.println(stmt2 + &quot; &lt;--localListByMap stmt2&quot;);
    rs2 = stmt2.executeQuery();

    ArrayList&lt;HashMap&lt;String, Object&gt;&gt; list2 = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;();// HashMap&lt;String,Object&gt;타입의 ArrayList를 만든다
    while(rs2.next()){
        HashMap&lt;String, Object&gt; m = new HashMap&lt;String, Object&gt;();
        m.put(&quot;localName&quot;, rs2.getString(&quot;localName&quot;)); // map.put(키이름, 값)
        m.put(&quot;country&quot;, rs2.getString(&quot;country&quot;));
        m.put(&quot;worker&quot;, rs2.getString(&quot;worker&quot;));
        list2.add(m);
    } // HashMap타입의 m에 rs의 값을 저장하고 만들어진 행을 list2에 추가한다</code></pre>
<h3 id="✅group-by절">✅GROUP BY절</h3>
<p>GROUP BY절이 있어야 집계함수를 이용할 수 있다
(이전에 GROUP BY절 없이 사용한 COUNT는 GROUP BY NULL이 생략된 형태)</p>
<blockquote>
<ul>
<li>GROUP BY : 컬럼별 집계후 집계함수(COUNT, SUM, AVG, MAX, MIN)를 사용하여 집계결과 출력</li>
<li>WITH ROLLUP : GROUP BY의 확장절로 group by되지 않은 전체 집계함수의 결과도 같이 출력</li>
<li>IFNULL(x, y) 함수 : x의 값이 null이면 y값으로 출력, null이 아니면 x값 출력</li>
<li>UNION ALL 집합연산자 : 두 select쿼리의 결과를 결합
출처: <a href="https://cafe.naver.com/jjdev">https://cafe.naver.com/jjdev</a></li>
</ul>
</blockquote>
<pre><code class="language-sql">-- GROUP BY절 집계함수
SELECT local_name, AVG(board_no) FROM board GROUP BY local_name;

SELECT local_name, COUNT(local_name) FROM board GROUP BY local_name;

-- WITH ROLLUP
SELECT IFNULL(local_name, &#39;전체&#39;), COUNT(local_name)
FROM board
GROUP BY local_name WITH ROLLUP;

-- UNITON ALL
SELECT local_name, COUNT(local_name) FROM board GROUP BY local_name
UNION ALL
SELECT &#39;전체&#39;, COUNT(local_name) FROM board;</code></pre>
<h3 id="💪느낀점">💪느낀점</h3>
<p>과제할 때 필요한 SQL을 조금씩 배워서 적용하고 있다.
SQL을 잘 사용하면 훨씬 간단하게 원하는 내용을 출력할 수 있기 때문에 앞으로 과제나 프로젝트를 위해 충분한 연습을 해야겠다.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 19일차: session, 로그인]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-19%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-19%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Fri, 05 May 2023 01:45:21 GMT</pubDate>
            <description><![CDATA[<p>드디어 기대하던 로그인 기능을 배우고 연습하였다.</p>
<h3 id="✅웹애플리케이션-사용자">✅웹애플리케이션 사용자</h3>
<blockquote>
<ul>
<li>브라우저 별 하나의 사용자 개념이다 (크롬과 엣지는 다른 사용자이고 같은 크롬도 브라우저별로 다른 사용자이다)</li>
</ul>
</blockquote>
<ul>
<li>웹서버는 사용자가 처음 접근하면 세션ID값을 부여하여 관리한다</li>
<li>웹서버는 부여한 세션ID값을 이용하여 동일한 사용자인지 구분한다(로그인 되면 마이페이지 등 로그인정보에 맞는 메뉴사용가능)</li>
<li>일정시간(디폴트 30분) 동안 연결이 없으면 웹서버는 세션ID를 삭제한다
출처: <a href="https://cafe.naver.com/jjdev">https://cafe.naver.com/jjdev</a></li>
</ul>
<h4 id="⌨세션id확인-세션강제갱신">⌨세션ID확인, 세션강제갱신</h4>
<pre><code class="language-java">// 세션ID확인
session.getId();

// 세션갱제갱신 (이전 세션 종료)
session.invalidate();</code></pre>
<h3 id="✅서버측-데이터-저장장소">✅서버측 데이터 저장장소</h3>
<blockquote>
<ul>
<li>page: 페이지 내에서만 사용 가능하고 페이지를 벗어나면 저장데이터(변수) 소멸</li>
</ul>
</blockquote>
<ul>
<li>session: 개별(브라우저 사용자) 클라이언트가 접근하는 모든 페이지에서 사용가능하고 일정 시간동안 접속 정보가 없으면 소멸</li>
<li>application: 톰캣과 같은 WAS프로그램내에 모든 사용자가 접근가능(공유)하며 WAS가 종료되면 소멸
출처: <a href="https://cafe.naver.com/jjdev">https://cafe.naver.com/jjdev</a></li>
</ul>
<pre><code class="language-java">    // 페이지 변수는 다른페이지에서 호출할 수 없다 -&gt; 컴파일 에러
    String name = &quot;page local variable : apple&quot;;
    // 페이지 속성 변수는 다른페이지에서 호출은 가능하지만 null값이 호출된다.
    pageContext.setAttribute(&quot;x&quot;, &quot;pageContext:apple&quot;);

    // 세션에 저장된 내용은 다른 페이지에서도 호출 가능
    session.setAttribute(&quot;y&quot;, &quot;session:banana&quot;);</code></pre>
<h3 id="✅로그인기능-구현하기">✅로그인기능 구현하기</h3>
<pre><code class="language-java">    // db에 폼에서 입력한 id(기본키)와 pw가 일치하는 행이 있으면 -&gt; 로그인 성공, 없으면 -&gt; 실패
    // select * from member where id=? and pw=?

    final String tableId = &quot;admin&quot;;
    final String tablePw = &quot;1234&quot;;

    if(tableId.equals(id) &amp;&amp; tablePw.equals(pw)) {
        System.out.println(&quot;loginAction 로그인 성공&quot;);
        // 로그인 성공 정보(사용자 ID만)를 세션에 저장
        session.setAttribute(&quot;loginId&quot;, id);
        response.sendRedirect(request.getContextPath()+&quot;/home.jsp&quot;);
    } else {
        System.out.println(&quot;loginAction 로그인 실패&quot;);
        String msg = URLEncoder.encode(&quot;ID와PW 다시입력&quot;, &quot;utf-8&quot;);
        response.sendRedirect(request.getContextPath()+&quot;/loginForm.jsp?msg=&quot;+msg);
    }</code></pre>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>오늘 배운 내용은 간단한데 머리속에서 정리가 안되는 느낌이다;;</li>
</ul>
<ol>
<li>로그인 id와 pw가 DB에 있으면 해당 값을 세션에 저장</li>
<li>로그아웃은 세션강제종료</li>
<li>로그인 후 이용가능한 메뉴는 세션에 값이 존재하는 경우(null이 아닌 경우)<pre><code class="language-java">// 로그인
session.setAttribute(&quot;id&quot;, &quot;admin&quot;);
// 로그아웃
session.invalidate();
// 로그인 상태에서만 사용가능
if(session.getAttribute(&quot;id&quot;) != null){
}</code></pre>
</li>
</ol>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 18일차: 같은 name속성을 가진 input 태그 값들을 받는 방법]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-18%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-18%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Fri, 05 May 2023 01:18:32 GMT</pubDate>
            <description><![CDATA[<p>그 동안은 동일한 name속성을 가진 input태그 값들을 하나씩 받았다.
checkbox의 경우 동일한 name속성으로 여러개의 값들을 보낼 수 있는데, 이를 받는 방법을 연습하였다.</p>
<h3 id="✅requestgetparametervalues">✅request.getParameterValues()</h3>
<ul>
<li>request.getParameterValues()로 input태그의 값들을 받으면 <code>String배열</code>로 값을 받는다</li>
<li>선택을 하지 않는 경우에는 <code>null</code>로 들어온다는 점을 유념하자(유효성검사를 하는 이유!)</li>
</ul>
<pre><code class="language-html">&lt;form action=&quot;#&quot; method=&quot;get&quot;&gt;
        &lt;input type=&quot;checkbox&quot; name=&quot;fruit&quot; value=&quot;apple&quot;&gt;사과
        &lt;input type=&quot;checkbox&quot; name=&quot;fruit&quot; value=&quot;orange&quot;&gt;오렌지
        &lt;button type=&quot;submit&quot;&gt;검색&lt;/button&gt;
&lt;/form&gt;</code></pre>
<pre><code class="language-java">    if(request.getParameterValues(&quot;fruit&quot;) != null) {
        for(String s : request.getParameterValues(&quot;fruit&quot;))    {
            System.out.println(s);    
        }
    }</code></pre>
<h3 id="⌨월별-검색">⌨월별 검색</h3>
<ul>
<li><p>1~12월의 checkbox를 만들고 선택된 월의 데이터만 보여주기</p>
</li>
<li><p>월이 선택된 개수에 따라 쿼리의 ?의 개수가 달라지는 부분을 주의한다</p>
<pre><code class="language-java">  //check박스의 값들이 잘 들어오는지 확인한다 
  System.out.println(request.getParameterValues(&quot;ckMonth&quot;));

  // String배열 변수 ckMonth에 파라미터값들을 담는다
  String[] ckMonth =  request.getParameterValues(&quot;ckMonth&quot;);

  // 추후 where절에서 DB의 월과 비교할 때 DB의 값은 숫자이기 때문에 숫자 배열로 형변환한다
  int[] intCkMonth = null; // int[] 대신에 ArrayList&lt;Integer&gt;를 사용할 수 있다
  if(ckMonth != null) {
      intCkMonth = new int[ckMonth.length]; // ckMonth길이이 같은 수
      for(int i=0; i&lt;intCkMonth.length; i+=1) {
          intCkMonth[i] = Integer.parseInt(ckMonth[i]);
      }
  }

  String sql = null;
  PreparedStatement stmt = null;

  if(intCkMonth == null) { // 선택된 월이 없으면 전체 데이터를 보여준다
      sql = &quot;SELECT * FROM employees LIMIT ?, ?&quot;;
      stmt = conn.prepareStatement(sql);
      stmt.setInt(1, startRow);
      stmt.setInt(2, rowPerPage);
  } else { // 선택된 월이 1개 이상일 때 
      sql = &quot;SELECT * FROM employees WHERE MONTH(hire_date) IN (?&quot;;
      // 쿼리에 ?의 개수를 셋팅
      for(int i=1; i&lt;intCkMonth.length; i+=1) {
          sql += &quot;,?&quot;;    
      }
      sql += &quot;) LIMIT ?, ?&quot;;

      stmt = conn.prepareStatement(sql);

      // 쿼리에 ?값을 셋팅
      for(int i=0; i&lt;intCkMonth.length; i+=1) {
          stmt.setInt(i+1, intCkMonth[i]);
      }
      stmt.setInt(intCkMonth.length+1, startRow);
      stmt.setInt(intCkMonth.length+2, rowPerPage);
  }
  System.out.println(stmt); // 쿼리 디버깅</code></pre>
<h3 id="💪느낀점">💪느낀점</h3>
</li>
<li><p>몸이 너무 안좋아서 오후에 조퇴했는데 오전에 오늘 진도는 다 들을 수 있어서 다행이었다. 남은 기간에는 건강관리를 더  잘해서 개발공부에 더 집중할 수 있도록 하자.</p>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 17일차: SQL WHERE절 연산자, 이름검색(WHERE절), ANSI코드]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-17%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-17%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Fri, 05 May 2023 00:57:05 GMT</pubDate>
            <description><![CDATA[<h3 id="✅where절에서-사용-가능한-연산자">✅WHERE절에서 사용 가능한 연산자</h3>
<pre><code class="language-sql">-- =, &lt;, &gt; 연산자는 문자, 숫자 모두 사용가능하다
SELECT * FROM employees
WHERE gender = &#39;M&#39; 
LIMIT 0, 10;

SELECT * FROM employees
WHERE emp_no = 10005; 

SELECT * FROM employees
WHERE emp_no &lt; 10005;

SELECT * FROM employees
WHERE first_name &lt; &#39;C&#39;;

-- IN, BETWEEN AND 연산자를 이용하여 반복없이 가독성 높은 sql을 작성할 수 있다.

SELECT * FROM employees
WHERE emp_no = 10005 OR emp_no = 10008;

SELECT * FROM employees
WHERE emp_no IN (10005, 10008);

SELECT * FROM employees
WHERE emp_no &gt;= 10005 and emp_no &lt;= 10008;

SELECT * FROM employees
WHERE emp_no BETWEEN 10005 and 10008;

-- 부분적으로 일치하는 행 찾기

SELECT * FROM employees
WHERE first_name LIKE &#39;Anneke&#39;;

SELECT * FROM employees
WHERE first_name = &#39;Anneke&#39;;

-- first_name이 A로 시작하는 행
SELECT * FROM employees
WHERE first_name LIKE &#39;A%&#39;;

-- first_name이 A로 끝나는 행
SELECT * FROM employees
WHERE first_name LIKE &#39;%a&#39;;

-- first_name에 ab가 들어가는 행
SELECT * FROM employees
WHERE first_name LIKE &#39;%ab%&#39;;

-- 이름 세글자 중 미가 들어가는 행
SELECT * FROM 학생
WHERE 이름 LIKE &#39;_미_&#39;;</code></pre>
<h3 id="✅이름검색">✅이름검색</h3>
<p>searchWord가 없는 경우는 전체를 보여주고, searchWord가 있는 경우는 이름에 해당 알파벳이 포함된 데이터만 보여준다</p>
<pre><code class="language-java">// 동적쿼리
    String sql = null;
    PreparedStatement stmt = null;
    if(searchWord.equals(&quot;&quot;) == true) { // searchWord 초기값은 공백
        sql = &quot;SELECT * FROM employees ORDER BY emp_no ASC LIMIT ?, ?&quot;;
        stmt = conn.prepareStatement(sql);
        stmt.setInt(1, startRow);
        stmt.setInt(2, rowPerPage);
    } else {
        /*
            SELECT * FROM employees 
            WHERE CONCAT(first_name, &#39; &#39;, last_name) LIKE ?
            ORDER BY emp_no ASC 
            LIMIT ?, ?
            // concat은 문자열을 합치는 함수
        */
        sql = &quot;SELECT * FROM employees WHERE CONCAT(first_name, &#39; &#39;, last_name) LIKE ? ORDER BY emp_no ASC LIMIT ?, ?&quot;;
        stmt = conn.prepareStatement(sql);
        stmt.setString(1, &quot;%&quot;+searchWord+&quot;%&quot;);
        stmt.setInt(2, startRow);
        stmt.setInt(3, rowPerPage);
    }</code></pre>
<h3 id="✅ansi코드-systemoutprintln-출력색상-변경">✅ANSI코드: System.out.println() 출력색상 변경</h3>
<ul>
<li>console에 출력된 디버깅코드들의 가독성이 높아진다.</li>
<li>팀프로젝트시 팀원들의 코드를 구별할 수 있다.
<a href="https://cafe.naver.com/jjdev">https://cafe.naver.com/jjdev</a></li>
</ul>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>어제 배운 정렬, 성별선택 기능과 검색기능을 어떻게 합칠 수 있을지 고민해보자.</li>
<li>ANSI코드를 추가하는 것은 손이 한번 더 가는 일이지만 지금부터 습관을 들여서 당연한 일이 되도록 만들자!</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 16일차: 샘플DB설치하기, SQL SELECT문 ORDER BY절, WHERE절, 동적쿼리]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-16%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-16%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Fri, 05 May 2023 00:35:43 GMT</pubDate>
            <description><![CDATA[<p>오늘은 mockaroo에서 만든 DB가 아닌 실제 샘플DB를 설치하고 이를 이용하여 쿼리를 연습하였다.</p>
<h3 id="✅mariadb-명령프롬프트-이용한-db추가">✅MariaDB 명령프롬프트 이용한 DB추가</h3>
<ol>
<li>샘플DB파일 압축해제</li>
<li>MariaDB command prompt 실행
<img src="https://velog.velcdn.com/images/jin_0/post/117530a1-554f-407a-87f4-9f40abe41e22/image.png" alt=""></li>
<li>cd 명령으로 압축해제 폴더로 이동 (ex: cd c:\employees)</li>
<li>mysql -u root -p명령으로 DB접속</li>
<li>source employees.sql; 실행</li>
<li>exit명령어로 종료</li>
<li>HeidiSQL에서 설치된 DB확인</li>
</ol>
<h3 id="✅동적쿼리">✅동적쿼리</h3>
<p>동적쿼리는 파라미터값에 따라 달라질 수 있는 쿼리를 말한다</p>
<h3 id="✅컬럼별-정렬order-by절">✅컬럼별 정렬(ORDER BY절)</h3>
<pre><code class="language-java">    /*
        데이터를 가져오기 위한 sql
        SELECT 
            emp_no empNo, 
            birth_date birthDate, 
            first_name firstName, 
            last_name lastName, 
            gender gender, 
            hire_date hireDate
        FROM employees
        ORDER BY emp_no ASC
        LIMIT ?, ?
        # order by를 지정하지 않고 select에 기본키(emp_no)가 있으면 기본키 오름차순으로 정렬된다 
        -&gt; 변수 col과 ascDesc의 초기값
    */
    String col = &quot;emp_no&quot;;
    String ascDesc = &quot;ASC&quot;;
    if(request.getParameter(&quot;col&quot;) != null 
            &amp;&amp; request.getParameter(&quot;ascDesc&quot;) != null) {
        col = request.getParameter(&quot;col&quot;);
        ascDesc = request.getParameter(&quot;ascDesc&quot;);
    }

    String sql = &quot;SELECT emp_no empNo, birth_date birthDate, first_name firstName, last_name lastName, gender gender, hire_date hireDate 
                    FROM employees ORDER BY &quot;+col+&quot; &quot;+ascDesc+&quot; LIMIT ?, ?&quot;;
    // 컬럼과 정렬방식 파라미터에 따라 쿼리가 달라진다</code></pre>
<h3 id="✅데이터-검색where절">✅데이터 검색(WHERE절)</h3>
<p>성별에 따라 달라지는 출력결과</p>
<pre><code class="language-java">    /*
        SELECT 
            emp_no empNo,
            birth_date birthDate,
            first_name firstName,
            last_name lastName,
            gender gender,
            hire_date hireDate
        FROM employees
        LIMIT ?,?
    */
    //쿼리생성
    String sql = null;
    PreparedStatement stmt = null;
    if(gender.equals(&quot;&quot;)) {
        sql = &quot;select emp_no empNo, birth_date birthDate, first_name firstName, last_name lastName, gender gender, hire_date hireDate from employees limit ?,?&quot;;
        stmt = conn.prepareStatement(sql); // ? 2개
        stmt.setInt(1,startRow);
        stmt.setInt(2,rowPerPage);
    } else {
        sql = &quot;select emp_no empNo, birth_date birthDate, first_name firstName, last_name lastName, gender gender, hire_date hireDate from employees where gender = ? limit ?,?&quot;;
        stmt = conn.prepareStatement(sql); // ? 3개
        stmt.setString(1, gender);
        stmt.setInt(2,startRow);
        stmt.setInt(3,rowPerPage);        
    }
    /* 
        gender를 선택하지 않으면 전체 데이터를 보여주고 성별을 선택하면 
        where절이 추가되어 해당 성별만 보여준다
   */</code></pre>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>정렬과 검색을 따로따로 구현할 때는 크게 어렵지 않았는데 모든 조건을 함께 구현하려고 하니 복잡도가 훨씬 증가한다. 
각각의 상황에 맞게 쿼리를 분기해야 해서, 모든 경우의 수를 놓치지 않도록 꼼꼼하게 코드를 작성해야겠다.</li>
<li>무작정 코드를 줄이기 보다는 깔끔하면서도 가독성이 좋은 코드를 작성하기 위해 고민하자.</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 15일차: ResultSet을 다른타입으로 변경하기]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-15%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-15%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Tue, 25 Apr 2023 23:42:56 GMT</pubDate>
            <description><![CDATA[<h3 id="✅resultset→arraylist다른-vo타입">✅ResultSet→ArrayList/다른 VO타입</h3>
<ul>
<li>자료구조에는 set, list, map이 있다.
set은 자료순서가 없고, list는 인덱스가 있기 때문에 순서가 있다.</li>
<li>따라서 특정환경에서만 사용하는 자료구조API인 ResultSet을 모든 자바코드에서 사용 가능한 일반적인 자료구조타입(list 혹은 다른VO타입)으로의 변경이 필요하다</li>
<li>결과값이 여러행인 경우에는 ArrayList로 변경하면 되고, 하나인 경우 int나 VO타입과 같이 결과값과 일치하는 타입으로 변경하면 된다</li>
</ul>
<h4 id="⌨결과값이-한-행인-경우">⌨결과값이 한 행인 경우</h4>
<p>ResultSet타입의 rs를 Notice타입으로 변경한다</p>
<pre><code class="language-java">ResultSet rs = stmt.executeQuery();
    // 모델데이터 
    Notice notice = null; // int totalCnt; ArrayList&lt;Notice&gt; list
    // Notice notice = new Notice();
    if(rs.next()) {
        notice = new Notice();
        notice.noticeNo = rs.getInt(&quot;notice_no&quot;);
        notice.noticeTitle = rs.getString(&quot;notice_title&quot;);
        notice.noticeContent = rs.getString(&quot;notice_content&quot;);
        notice.noticeWriter = rs.getString(&quot;notice_writer&quot;);
        notice.createdate = rs.getString(&quot;createdate&quot;);
        notice.updatedate = rs.getString(&quot;updatedate&quot;);
    }</code></pre>
<h4 id="⌨결과값이-여러-행인-경우">⌨결과값이 여러 행인 경우</h4>
<p>ResultSet타입의 rs를 ArrayList로 변경한다</p>
<pre><code class="language-java">ResultSet rs = stmt.executeQuery();    
    // 자료구조 ResultSet타입을 일반적인 자료구조타입(자바 배열 or 기본API 자료구조타입 List, Set, Map)
    // ResultSet -&gt; ArrayList&lt;Notice&gt;
    ArrayList&lt;Notice&gt; noticeList = new ArrayList&lt;Notice&gt;();
    while(rs.next()) {
        Notice n = new Notice();
        n.noticeNo = rs.getInt(&quot;noticeNo&quot;);
        n.noticeTitle = rs.getString(&quot;noticeTitle&quot;);
        n.createdate = rs.getString(&quot;createdate&quot;);
        noticeList.add(n);
    }</code></pre>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>내가 만들어가는 페이지에 새로 배운 부분이 얹어지면서 점점 나아지고 있는 것에 뿌듯함이 느껴지고, 앞으로 새로운 기능을 구현하게 될 것이 벌써부터 기대된다!</li>
<li>과제로 ResultSet타입을 다른 자료구조로 바꾸라고 하셨을 때 아무런 생각없이 ArrayList로 모두 바꾸고 있었다. 
그런데 다른 분들의 질문으로 한 행일 경우에는 list로 받을 필요가 없다는 것을 깨달았다. 
이 부분은 정말 생각지도 않고 있었다;;
그냥 복사-붙여넣기가 아니라 왜 이 코드가 작성되어야 하는지를 생각하며 코드를 작성해야 함을 항상 잊지말자!</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 14일차: diary프로젝트 일정등록,수정,삭제]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-14%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-14%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Mon, 24 Apr 2023 11:43:49 GMT</pubDate>
            <description><![CDATA[<p>오늘은 국비지원 14일차가 되었다. 
지난주에 이어 diary프로젝트를 계속하면서 DB에 데이터를 입력, 수정, 삭제하고 JSP파일에서 DB데이터를 조회하는 연습을 계속하였다.</p>
<h3 id="✅오늘의-작업">✅오늘의 작업</h3>
<ul>
<li>home.jsp : 오늘의 일정 부분을 추가</li>
<li>scheduleList.jsp : 달력을 출력하고 해당 날짜의 일정 일부분을 보여준다</li>
<li>scheduleListByDate.jsp : 하루의 일정 리스트와 일정을 추가할 수 있는 폼을 보여준다</li>
<li>insertScheduleAction.jsp : 일정을 추가하면 mariaDB에 일정이 추가된다</li>
<li>updateScheduleForm.jsp : 일정을 수정하는 폼</li>
<li>updateScheduleAction.jsp : 일정을 수정하면 mariaDB에서 일정이 수정된다</li>
<li>deleteScheduleForm.jsp : 일정을 삭제하는 폼</li>
<li>deleteScheduleForm.jsp : 일정을 삭제하면 mariaDB에서 일정이 삭제된다</li>
</ul>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>오늘 마지막에 시간에 쫓기듯이 코딩을 하느라 제대로 생각하고 하지 못하고 복붙만 하다 끝났다. 수업시간에 부족한 부분은 집에서 하면 되니까 조급해하지 말고 차근차근 하나라도 제대로 끝내도록 하자!</li>
<li>스스로에 대해 믿음을 가지고 서두르지 말자!</li>
<li>그래도 공지부분과 비슷한 내용이 반복되니 코딩이 조금은 익숙해진 것 같다.</li>
<li>❗❗ 디버깅과 주석은 아무리 강조해도 모자라다 ❗❗</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 13일차: diary프로젝트(UPDATE문)]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-13%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-13%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Fri, 21 Apr 2023 04:23:02 GMT</pubDate>
            <description><![CDATA[<p>오늘은 어제에 이어 JSP파일에서 MariaDB에 접속하여 데이터를 수정하는 방법을 연습하였다.</p>
<h3 id="✅오늘의-작업">✅오늘의 작업</h3>
<ul>
<li>updateNoticeForm.jsp : 공지상세내용을 수정할 수 있다</li>
<li>updateNoticeAction.jsp : 공지를 수정하면 mariaDB에서 수정된다</li>
</ul>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>가장 중요한 것은 능동적으로 배우는 태도. 내가 작성하는 코드 한자 한자 무슨 의미인지 정확하게 이해하고 누군가에게 보여주기 위해서가 아닌 스스로 훈련하는 자세로 연습하자.</li>
<li>모든 코드에는 이유가 있다. 특히 디버깅코드는 실제로 확인까지 완료해야 의미가 있는 것이다. </li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 11일차: diary프로젝트(list만들기, page)]]></title>
            <link>https://velog.io/@jin_0/%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-11%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-11%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Wed, 19 Apr 2023 04:49:42 GMT</pubDate>
            <description><![CDATA[<p>구디아카데비 국비지원 과정 11일차!
오늘은 그동안 배운것을 활용하여 공지사항과 일정을 입력할 수 있는 폼을 만드는 작업을 시작하였다.</p>
<h3 id="✅오늘의-작업">✅오늘의 작업</h3>
<ul>
<li>home.jsp : 공지사항 5개와오늘의 일정 리스트를 보여준다</li>
<li>noticeOne.jsp : 공지사항의 상세내용을 보여준다</li>
<li>noticeList : 공지사항의 전체 리스트를 보여준다</li>
</ul>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>수업시간에 실습한 내용은 코드를 졸면서도 칠 수 있을때까지 연습해야한다. 제한된 시간에 자격증준비까지 효율적으로 할 수 있게 자투리시간 활용하기!</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 10일차: RDBMS(mariaDB)]]></title>
            <link>https://velog.io/@jin_0/%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-10%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-10%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Tue, 18 Apr 2023 04:26:19 GMT</pubDate>
            <description><![CDATA[<p>구디아카데미에서의 국비지원과정이 벌써 10일차가 되었다.
새로운 기술을 익히다 보니 하루가 참 빠르게 흘러간다. 
오늘은 MariaDB를 이용해 데이터의 입력, 수정, 삭제, 조회를 연습해보았다. </p>
<h3 id="✅mariadb를-이용하여-데이터베이스-만들기">✅MariaDB를 이용하여 데이터베이스 만들기</h3>
<p>MariaDB&gt;diary데이터베이스&gt;notice테이블</p>
<pre><code class="language-sql"># table 만드는 SQL쿼리 - DDL(create, alter, drop)
# table 사용을 허가하는 권한 - DCL (grant, revoke)
# table 데이터를 입력/수정/삭제/조회 - DML (insert, update, delete, select)
# select는 데이터를 변경시키지 않아 DML과 따로보는 것이 트렌드!
# TCL(commit, rollback)

# 입력
INSERT INTO notice(
    notice_title, 
    notice_content, 
    notice_writer,
    createdata,
    updatedata
) VALUES(
    &#39;첫번째공지&#39;,
    &#39;안녕하세요&#39;,
    &#39;구디&#39;,
    NOW(),
    NOW()    
);
# COMMIT; #heidiSQL안에 auto commit 옵션 on

# 수정
UPDATE notice SET notice_content=&#39;안녕히가세요&#39;
WHERE notice_no = 2;

# 삭제 (데이터는 한 행을 의미하므로 특정한 열만 삭제할 수 없다)
DELETE FROM notice WHERE notice_writer=&#39;구디2&#39;;

# 조회
SELECT * FROM notice;

# 원하는 행만 조회
SELECT * FROM notice WHERE notice_no=2; 
# 원하는 열만 조회
SELECT notice_no, notice_title FROM notice;

# 정렬(오름차순, 내림차순)
SELECT notice_no, notice_title FROM notice
ORDER BY notice_no DESC;

# 목록에서 504번 글의 제목을 클릭하면 504번 글의 모든 컬럼값을 조회
SELECT * FROM notice WHERE notice_no = 504; 

# 제한된 수의 데이터 조회 (0부터 10개)
SELECT notice_no, notice_title FROM notice
ORDER BY notice_no DESC
LIMIT 0, 10;</code></pre>
<h4 id="❗샘플데이터-만들기">❗샘플데이터 만들기</h4>
<p><a href="http://www.mockaroo.com/">http://www.mockaroo.com/</a></p>
<h3 id="✅jsp에서-mariadb의-데이터-불러오기">✅JSP에서 MariaDB의 데이터 불러오기</h3>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@ page import = &quot;java.sql.Connection&quot; %&gt;
&lt;%@ page import = &quot;java.sql.DriverManager&quot; %&gt;
&lt;%@ page import = &quot;java.sql.PreparedStatement&quot;%&gt;
&lt;%@ page import = &quot;java.sql.ResultSet&quot; %&gt;
&lt;%
    // select 쿼리를 maiadb에 전송 후 결과셋을 받아서 출력하는 페이지
    // select notice_no, notice_title from notice order by notice_no desc
    // **list는 순서가 있고 중복가능, set은 순서가 없고 중복 불가능

    // 1) mariadb 프로그램을 사용가능 하도록 장치드라이버를 로딩(메모리에 올린다)
    Class.forName(&quot;org.mariadb.jdbc.Driver&quot;); 
    // ** Class.forName은 static메소드, 값으로 클래스이름인 String이 들어온다
    System.out.println(&quot;드라이버 로딩 성공&quot;);

    // 2) mariadb에 로그인 후 접속정보 반환받아야 한다
    Connection conn = null; // 접속정보 타입
    conn = DriverManager.getConnection(&quot;jdbc:mariadb://127.0.0.1:3306/diary&quot;,&quot;root&quot;,&quot;비밀번호&quot;);
    System.out.println(&quot;접속성공&quot; + conn + &quot;&lt;-- conn의 참조&quot;);

    // 3) 쿼리생성 수 실행
    String sql = &quot;select notice_no, notice_title from notice order by notice_no desc&quot;;
    // 문자열을 쿼리로 바꿔준다
    PreparedStatement stmt = conn.prepareStatement(sql);

    // 쿼리를 실행하고 반환받은 값을 rs에 저장한다
    ResultSet rs = stmt.executeQuery();
    System.out.println(&quot;쿼리실행성공&quot; + rs + &quot;&lt;-- rs의 참조&quot;);
    // resultset은 순서(번호)가 없어서 foreach문 사용불가
    // ResultSet은 org.mariadb.jdbc.client.result.CompleteResult의 부모타입 -&gt;다형성

%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;title&gt;noticeList.jsp&lt;/title&gt;
    &lt;!-- Latest compiled and minified CSS --&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css&quot;&gt;

    &lt;!-- Latest compiled JavaScript --&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
    &lt;div class=&quot;container&quot;&gt;
        &lt;table class=&quot;table table-bordered&quot;&gt;
            &lt;tr&gt;
                &lt;th&gt;notice_no&lt;/th&gt;
                &lt;th&gt;notice_title&lt;/th&gt;
            &lt;/tr&gt;

            &lt;%
                // 커서를 한칸씩 내리면서 데이터가 있으면 true, 없으면 false반환
                // while은 false가 나올때까지 반복
                while(rs.next()) {
            %&gt;
                    &lt;tr&gt;
                        &lt;td&gt;&lt;%=rs.getInt(&quot;notice_no&quot;)%&gt;&lt;/td&gt;
                        &lt;td&gt;&lt;%=rs.getString(&quot;notice_title&quot;)%&gt;&lt;/td&gt;
                    &lt;/tr&gt;
            &lt;%
                }
            %&gt;
        &lt;/table&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>나는 수업내용에 대해 받아드릴 시간이 필요한 사람이다. 짧더라도 수업시간에 충분히 오늘의 내용을 음미하지 못했다면 통원시간이나 자기 전 블로그를 통해 다시 연습한 내용을 복기하자!</li>
<li>수업과 바로 연결되지는 않지만 정보처리기사의 시험이 얼마 남지 않았다! 과정 내에 정처기 시험은 이번 회차 뿐이므로 자투리 시간 낭비하지 않고 공부하자!</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 9일차: 지난주 복습, 달력만들기]]></title>
            <link>https://velog.io/@jin_0/%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-9%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-9%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Mon, 17 Apr 2023 02:59:31 GMT</pubDate>
            <description><![CDATA[<p>구디아카데미 9일차!
Java.. 쉽지 않다;;;</p>
<h3 id="✅문법-복습">✅문법 복습</h3>
<blockquote>
<ul>
<li><code>컴퓨터 랭기지</code> : 데이터(값) + 기능(연산, 함수)</li>
</ul>
</blockquote>
<ul>
<li><code>값</code> : 숫자(1, 3, 10, ...), 내부적으로 숫자에 맵핑된 문자하나 (&#39;A&#39;, &#39;B&#39;, &#39;가&#39;), 맵핑 논리값(true, false) </li>
<li><code>값연산(피연산자의 타입이 동일)</code> : +, -, *, /, %, &gt;, &lt;, &amp;&amp;, ||,...</li>
<li><code>변수</code> : 값을 저장했다가 재사용하기 위해서, <code>할당연산자</code>(=, +=)</li>
<li><code>타입(자료형)</code> : 변수와 값의 범위(모양) 일치</li>
<li>byte(1byte), short(2byte), int(4byte), long(8byte), float(4byte), double(8byte), char(2byte), boolean(true, false) --&gt; 변수에 데이터 값이 저장된다 (cf: 8bit = 1byte)
(float과 double은 부동소수점 방식)
(글자에 어떤 숫자를 맵핑했는지에 따라 인코딩 방식이 달라짐. 단, 0~256사이에는 항상 알파벳 맵핑-&gt;인코딩방식 상관없이 영어는 깨지지 않음)</li>
<li><code>랩퍼타입</code> : 기본타입과 동일한 참조타입</li>
</ul>
<hr>
<blockquote>
<ul>
<li><code>기본타입(단일 데이터 값, 스칼라)</code> vs <code>참조타입(복수 데이터 값, 집합, 벡터)</code></li>
</ul>
</blockquote>
<ul>
<li><code>배열</code> : 자료형이 같은 여러 데이터 값의 집합, 배열참조변수 -&gt; 인덱스, <code>[]연산자</code> -&gt; 개별값에 접근
<code>String[] names = new String[3]; names[2] = &quot;홍길동&quot;;</code></li>
<li><code>클래스(1)</code> : 사용자 정의 타입, 여러 자료형을 가진 데이터값의 집합, 객체참조변수 -&gt; 필드(멤버변수)이름, <code>.연산자</code> -&gt; 개별값에 접근
<code>Person p = new Person(); p.name = &quot;홍길동&quot;;</code></li>
<li><code>클래스(2)</code> : 메서드의 정의를 가지는 명세</li>
<li>메서드 : 클래스 안에 정의된 함수, 입력값을 받아 기능을 실행하고 반환값을 남기는 식 -&gt; 연산자
(자바에는 함수가 없다 = 클래스 밖에 선언된 함수가 없다)</li>
<li>일반메서드 vs static메서드
<code>ex) 일반메서드 A a = new A(); a.test();</code>
<code>ex) static메서드 A.test();</code></li>
</ul>
<hr>
<blockquote>
<ul>
<li>코드실행문장 위-&gt;아래 </li>
</ul>
</blockquote>
<ul>
<li>문장에서 <code>제어문</code>가능: <code>분기문</code>(<code>조건문</code>: if, switch, try...catch(예외처리에 쓰는 분기)), <code>루프문</code>(<code>반복문</code>: while, for, foreach)</li>
</ul>
<hr>
<blockquote>
<ul>
<li>기본 라이브러리(API), 외부 라이브러리(API)</li>
</ul>
</blockquote>
<ul>
<li>클래스 하나, 클래스 여러개-&gt;패키지, 패키지 여러개-&gt;모듈 --&gt;배포형식</li>
</ul>
<h3 id="✅기본-api-calendar">✅기본 API: Calendar</h3>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@ page import = &quot;java.util.Calendar&quot; %&gt; &lt;!-- 실행파일은 java폴더&gt;util폴더&gt;Calendar.class폴더 --&gt;
&lt;%
    // Calendar c = new Calendar(); // 문법적으로 왜 완되는지는 나중에...
    Calendar c = Calendar.getInstance();    
    String yoil = &quot;&quot;;
    switch(c.get(Calendar.DAY_OF_WEEK)) {
    case 1:
        yoil = &quot;일&quot;;
        break;
    case 2:
        yoil = &quot;월&quot;;
        break;
    case 3:
        yoil = &quot;화&quot;;
        break;
    case 4:
        yoil = &quot;수&quot;;
        break;
    case 5:
        yoil = &quot;목&quot;;
        break;
    case 6:
        yoil = &quot;금&quot;;
        break;
    default:
        yoil = &quot;토&quot;;
    }
%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Calendar&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div&gt;Calendar.getInstance() : &lt;%=c%&gt;&lt;/div&gt;
    &lt;!-- &lt;div&gt;Year : &lt;%=c.get(1)%&gt;&lt;/div&gt; --&gt;
    &lt;div&gt;Year : &lt;%=c.get(Calendar.YEAR)%&gt;&lt;/div&gt; &lt;!-- 코드의 가독성을 위해 상수1 대신 변수 사용 --&gt;
    &lt;div&gt;Month : &lt;%=c.get(Calendar.MONTH)%&gt;(+1해서 읽어야한다)&lt;/div&gt; &lt;!-- MONTH는 0(1월)~11(12월) --&gt;
    &lt;div&gt;Date : &lt;%=c.get(Calendar.DATE)%&gt;&lt;/div&gt;
    &lt;div&gt;이번주의 몇번째 날 : &lt;%=c.get(Calendar.DAY_OF_WEEK)%&gt;&lt;/div&gt; &lt;!-- 요일 개념은 없고 이번주 몇번째 날인지 출력 1(월)~7(토)--&gt;
    &lt;div&gt;현재달의 마지막 날자 : &lt;%=c.getActualMaximum(Calendar.DATE)%&gt;&lt;/div&gt;
    &lt;div&gt;요일 : &lt;%=yoil%&gt;&lt;/div&gt;
    &lt;!-- 
    변수이름: girlFriend
    클래스이름: GirlFriend
    static필드: GIRL_FRIEND
    jsp파일을 톰캣이 자바코드로 바꿔 실행 -&gt; 기계가 만든 파일은 소문자 사용
    --&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="✅달력과-일정입력폼">✅달력과 일정입력폼</h3>
<p><img src="https://velog.velcdn.com/images/jin_0/post/2db39818-293c-46e9-9e2e-700e86af011a/image.png" alt=""></p>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@ page import = &quot;java.util.Calendar&quot; %&gt;
&lt;%
    int targetYear = 0;
    int targetMonth = 0;

    // targetYear 혹은 targetMonth가 null이면 현재 년도와 월을 대입한다
    if(request.getParameter(&quot;targetYear&quot;) == null
            || request.getParameter(&quot;targetMonth&quot;) == null) {
        Calendar today = Calendar.getInstance();
        targetYear = today.get(Calendar.YEAR);
        targetMonth = today.get(Calendar.MONTH); 
    } else {
        targetYear = Integer.parseInt(request.getParameter(&quot;targetYear&quot;));
        targetMonth = Integer.parseInt(request.getParameter(&quot;targetMonth&quot;));
        if(targetMonth == -1) { // Month는 0(1월)~11(12월)
            targetMonth = 11;
            targetYear = targetYear - 1;
        } else if(targetMonth == 12) {
            targetMonth = 0;
            targetYear = targetYear + 1;
        }
    }

    // 일정입력을 위한 targetDate 선언
    int targetDate = 0;

    // 디버깅
    // http://localhost/ex17/calendar.jsp?targetYear=2023&amp;targetMonth=11
    // http://localhost/ex17/calendar.jsp
    System.out.println(targetYear + &quot; &lt;-- targetYear&quot;);
    System.out.println(targetMonth + &quot; &lt;-- targetMonth&quot;);

    // 달력 1일 앞의 공백(td) 수
    // 현재월의 1일의 DAY_OF_WEEK(일 1, 월 2, ... 토 7 ) - 1
    int startTdBlank = 0;
    // 출력하고자 하는 년/월/1일
    Calendar firstDate = Calendar.getInstance();
    firstDate.set(Calendar.YEAR, targetYear);
    firstDate.set(Calendar.MONTH, targetMonth);
    firstDate.set(Calendar.DATE, 1); // firstDate는 TargetYear, TargetMonth의 1일
    startTdBlank = firstDate.get(Calendar.DAY_OF_WEEK) - 1; 
    System.out.println(startTdBlank + &quot; &lt;-- startTdBlank&quot;);

    // 출력하고자 하는 년/월/마지막날짜
    int endDateNum = firstDate.getActualMaximum(Calendar.DATE); // getMaximum(Calendar.DATE)는 달력 전체의 월중 가장 긴 날짜
    System.out.println(endDateNum + &quot; &lt;-- endDateNum&quot;);

    // 달력 마지막날짜 출력후 공백(td) 수 
    int endTdBlank = 0;
    if((startTdBlank + endDateNum) % 7 != 0) {
        endTdBlank = 7-((startTdBlank + endDateNum)%7);
    }
    int totalTdCnt = startTdBlank + endDateNum + endTdBlank;

    // 지난달 마지막 날짜
    Calendar lastMonth = Calendar.getInstance();
    lastMonth.set(Calendar.YEAR, targetYear);
    lastMonth.set(Calendar.MONTH, targetMonth - 1);
    int lastEndDate = lastMonth.getActualMaximum(Calendar.DATE);
    System.out.println(lastEndDate + &quot; &lt;-- lastEndDate&quot;);
%&gt;

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;title&gt;calendar.jsp&lt;/title&gt;
    &lt;!-- Latest compiled and minified CSS --&gt;
    &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;&gt;

    &lt;!-- Latest compiled JavaScript --&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div class=&quot;container&quot;&gt;
    &lt;h1 class=&quot;text-center&quot;&gt;
        &lt;a href=&quot;./calendar.jsp?targetYear=&lt;%=targetYear%&gt;&amp;targetMonth=&lt;%=targetMonth-1%&gt;&quot;&gt;이전달&lt;/a&gt;
        &lt;%=targetYear%&gt;년 &lt;%=targetMonth+1%&gt;월
        &lt;a href=&quot;./calendar.jsp?targetYear=&lt;%=targetYear%&gt;&amp;targetMonth=&lt;%=targetMonth+1%&gt;&quot;&gt;다음달&lt;/a&gt;
    &lt;/h1&gt;
    &lt;table class=&quot;table table-bordered&quot;&gt;
        &lt;thead&gt;
            &lt;tr class=&quot;text-center&quot;&gt;
                &lt;th&gt;일&lt;/th&gt;
                &lt;th&gt;월&lt;/th&gt;
                &lt;th&gt;화&lt;/th&gt;
                &lt;th&gt;수&lt;/th&gt;
                &lt;th&gt;목&lt;/th&gt;
                &lt;th&gt;금&lt;/th&gt;
                &lt;th&gt;토&lt;/th&gt;        
            &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tr&gt;
            &lt;%
                for(int i=0; i&lt;totalTdCnt; i++) {
                    // i가 7의 배수일 때 행을 바꾼다
                    if(i%7==0) {
            %&gt;
                        &lt;/tr&gt;&lt;tr&gt;
            &lt;%        
                    }

                    // targetMonth의 날짜 표시
                    int dateNum = i - startTdBlank + 1;
                    // targetMonth의 1일~마지막날짜까지 출력
                    if(dateNum &gt; 0 &amp;&amp; dateNum &lt;= endDateNum) {
                        // 일요일 빨간색
                        if(i%7==0) {
            %&gt;
                             &lt;td&gt;&lt;a class=&quot;text-danger text-decoration-none&quot; 
                                 href=&quot;./calendarSchedule.jsp?targetYear=&lt;%=targetYear%&gt;&amp;targetMonth=&lt;%=targetMonth%&gt;&amp;targetDate=&lt;%=targetDate%&gt;&quot;&gt;
                                 &lt;%=dateNum%&gt;&lt;/a&gt;&lt;/td&gt;
            &lt;%
                        // 일요일을 제외하고 검정색
                        } else {
            %&gt;
                            &lt;td&gt;&lt;a class=&quot;text-body text-decoration-none&quot; href=&quot;&quot;&gt;&lt;%=dateNum%&gt;&lt;/a&gt;&lt;/td&gt;
            &lt;%
                        }
                    // 1일 앞에 지난달 날짜 채우기, 회색글씨와 음영처리
                    } else  if (dateNum &lt;= 0){
            %&gt;
                         &lt;td class=&quot;table-secondary&quot;&gt;&lt;a class=&quot;text-muted text-decoration-none&quot; href=&quot;&quot;&gt;&lt;%=lastEndDate + dateNum%&gt;&lt;/a&gt;&lt;/td&gt; 
            &lt;%            
                    // 마지막 날짜 뒤에 다음달 날짜 채우기, 회색글씨와 음영처리
                    } else {
            %&gt;
                        &lt;td class=&quot;table-secondary&quot;&gt;&lt;a class=&quot;text-muted text-decoration-none&quot; href=&quot;&quot;&gt;&lt;%=dateNum - endDateNum%&gt;&lt;/a&gt;&lt;/td&gt;
            &lt;%
                    }
                }
            %&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p><img src="https://velog.velcdn.com/images/jin_0/post/7f320c6b-9191-4585-bd9e-105044e8300b/image.png" alt=""></p>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%
    int targetYear = Integer.parseInt(request.getParameter(&quot;targetYear&quot;));
    int targetMonth = Integer.parseInt(request.getParameter(&quot;targetMonth&quot;));
    int targetDate = Integer.parseInt(request.getParameter(&quot;targetDate&quot;));
%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;calendarSchedule&lt;/title&gt;
    &lt;!-- Latest compiled and minified CSS --&gt;
    &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;&gt;

    &lt;!-- Latest compiled JavaScript --&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form action=&quot;#&quot; method=&quot;post&quot;&gt;
        &lt;div class=&quot;container&quot;&gt;
        &lt;h1&gt;&lt;%=targetYear%&gt;년 &lt;%=targetMonth + 1%&gt;월 &lt;%=targetDate%&gt;일&lt;/h1&gt;
        &lt;h2&gt;일정입력&lt;/h2&gt;
            &lt;table&gt;
                &lt;tr&gt;
                    &lt;th&gt;제목&lt;/th&gt;
                    &lt;td&gt;&lt;input type=&quot;text&quot; &gt;&amp;nbsp;&lt;input type=&quot;checkbox&quot;&gt;중요&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;th&gt;장소&lt;/th&gt;
                    &lt;td&gt;&lt;input type=&quot;text&quot;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;th&gt;일시&lt;/th&gt;
                    &lt;td&gt;&lt;input type=&quot;datetime-local&quot;&gt; - &lt;input type=&quot;datetime-local&quot;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;th style=&quot;vertical-align: top&quot;&gt;설명&lt;/th&gt;
                    &lt;td&gt;&lt;textarea cols=&quot;60&quot; rows=&quot;8&quot;&gt;&lt;/textarea&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td colspan=&quot;2&quot;&gt;&lt;button type=&quot;submit&quot;&gt;저장&lt;/button&gt;&amp;nbsp;&amp;nbsp;&lt;button type=&quot;submit&quot;&gt;취소&lt;/button&gt;&lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
        &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>업무분석!이 안되니 실습에서 많은 시간이 소요된다ㅠ 익숙해진다고 하지만 사람인지라 잘하는 친구들을 보면 조급한 마음이ㅠㅠ 일단은 할 수 있는 것은 빠르게 하고 모르는 부분은 선생님께 물어볼 수 있도록 체크해놓자!</li>
<li>9일차인 지금도 주석을 다는 것을 놓친다. 꼼꼼히 적어놓은 다른 사람들의 주석을 참고해서 주석을 놓치지 않도록 하자!</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 8일차: 형변환, ArrayList, 랩퍼타입, 리스트만들기, 부트스트랩]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-8%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-8%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Fri, 14 Apr 2023 02:08:55 GMT</pubDate>
            <description><![CDATA[<p>벌써 구디아카데미에서의 두번째 주가 지났다.
오늘은 어제에 이어 리스트를 만들었는데 앞으로 가장 많이 만들게 되는 것이 리스트라고 하셨다.
아직 배열과 ArrayList가 익숙하지 않지만;; 곧 익숙해지겠지!</p>
<h3 id="✅형변환">✅형변환</h3>
<pre><code class="language-java">    // 기본타입간에 형변환 가능 (boolean 제외)
    // 참조타입간에 형변환 가능 
    // 기본타입과 참조타입간에는 형변환 불가 (메모리의 모양이 같아야 함)
    // ex) int x = Integer.parseInt(&quot;14&quot;); &lt;-- 형변환 아님!    
    int x = 10;
    double dx = (double)x; // 데이터손실X -&gt; 형변환 연산자 생략가능(자동형변환)

    double dy = 3.0; 
    int y = (int)dy; // 데이터손실O -&gt; 형변환 연산자 생략불가(명시적형변환)

    float fz = 3.14F;
    long z = (long)fz; // 10L (long)10
    // 자동형변환X -&gt; float가 long보다 물리적크기는 작지만 값을 표현하는 범위가 크다
    // float 값표현방식에 오차를 허용하는 &quot;부동소주점 방식&quot;을 사용하기 때문
    // ()는 형변환연산자 -&gt; 앞에 위치하고 데이터타입이 들어온다
    // Math.random()에서 ()는 호출연산자 -&gt; 뒤에 위치하고 값이 들어온다</code></pre>
<h3 id="✅arraylist와-랩퍼박싱타입">✅ArrayList와 랩퍼(박싱)타입</h3>
<pre><code class="language-java">// 랩퍼타입 8개
    Byte a = new Byte((byte)1);
    Short b = new Short((short)2);
    Integer c = new Integer(3);
    Long d = new Long(4L);
    Character e = new Character(&#39;가&#39;);
    Float f = new Float(3.14);
    Double g = new Double(3.12);
    Boolean h = new Boolean(true);    

    Integer c2 = 3; // auto boxing 기본타입을 참조타입으로 자동 변환
    int x = c2; // auto unboxing 참조타입으로 기본타입으로 자동 변환

    int y = Integer.parseInt(&quot;777&quot;); 
    // String- (참조타입형변환) -&gt; Integer -(언박싱)-&gt; int</code></pre>
<h3 id="⌨해적단-리스트-만들기">⌨해적단 리스트 만들기</h3>
<ul>
<li><p>Pirate 클래스 생성
```java
package onepiece;
import java.util.ArrayList;
public class Pirate {
  public String name;
  public String nickName;
  public char gender; // &#39;M&#39;/&#39;F&#39; 출력시 남여이미지
  public String birth;
  public int age;
  public int height;
  public ArrayList<String> hobby; // ★★★★★
  public String blood;
  public String country;
  public long money;
  public String group; // 해적(소속)
  public boolean isDevilFruit; // 악마의열매 섭취유무, 출력시 이미지
  // ArrayList<int> a ; 불가능
  // ArrayList<Integer> a; 가능
}
/*    
  ArrayList<Pirate> list = new ArrayList<Pirate>();
  Pirate p = new Pirate();
  p.name = &quot;홍길동&quot;;
  p.hobby = new ArrayList<String>();
  p.hobby.add(&quot;야구&quot;);
  p.hobby.add(&quot;클라이밍&quot;);
  list.add(p); 
  // 읽기
  System.out.println(list.get(0).name);
  System.out.println(list.get(0).hobyy[1]);
  for(Pirate e : list) {</p>
<pre><code>  System.out.println(e.name);
  for(String h : e.hobby) {
      System.out.println(h);
  }</code></pre><p>  }</p>
</li>
<li><p>/
```</p>
</li>
<li><p>리스트 만들기</p>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@ page import=&quot;java.util.ArrayList&quot; %&gt;
&lt;%@ page import=&quot;onepiece.Pirate&quot; %&gt;
&lt;%
  // 원칙은 RDBMS(오라클, MySQL(MariaDB), MSSQL)에서 데이터를 불러와서
  // 코드상에서 사용가능한 형태(ArrayList&lt;Pirate&gt;)로 변경

  // ArrayList 생성
  ArrayList&lt;Pirate&gt; list = new ArrayList&lt;Pirate&gt;();

  // Pirate 객체를 20개 생성
  // 해적1
  Pirate p1 = new Pirate();
  p1.name =&quot;몽키 D. 루피&quot;;
  p1.nickName = &quot;밀짚모자&quot;;
  p1.gender = &#39;M&#39;;
  p1.birth = &quot;5월 5일&quot;;
  p1.age = 19;
  p1.height = 174;
  p1.hobby = new ArrayList&lt;String&gt;(); // hobby도 ArrayList이기 때문에 초기화 후 값 입력
  p1.hobby.add(&quot;모험&quot;);
  p1.hobby.add(&quot;잔치&quot;);
  p1.blood = &quot;F형 (B형)&quot;;
  p1.country = &quot;이스트 블루 고아 왕국 후샤 마을&quot;;
  p1.money = 3000000000L;
  p1.group = &quot;밀짚모자 일당&quot;;
  p1.isDevilFruit = true;
  list.add(p1);

  // 해적2
  Pirate p2 = new Pirate();
  p2.name = &quot;롤로노아 조로&quot;;
  p2.nickName = &quot;해적 사냥꾼&quot;;
  p2.gender = &#39;M&#39;;
  p2.birth = &quot;11월 11일&quot;;
  p2.age = 21;
  p2.height = 181;
  p2.hobby = new ArrayList&lt;String&gt;();
  p2.hobby.add(&quot;음주&quot;);
  p2.hobby.add(&quot;수행&quot;);
  p2.blood = &quot;XF형 (AB형)&quot;;
  p2.country = &quot;이스트 블루 시모츠키 마을&quot;;
  p2.money = 1111000000L;
  p2.group = &quot;밀짚모자 일당&quot;;
  p2.isDevilFruit = false;
  list.add(p2);

  // 해적3
  Pirate p3 = new Pirate();
  p3.name = &quot;나미&quot;;
  p3.nickName = &quot;도둑고양이&quot;;
  p3.gender = &#39;F&#39;;
  p3.birth = &quot;7월 3일&quot;;
  p3.age = 20;
  p3.height = 170;
  p3.hobby = null;
  p3.blood = &quot;X형 (A형)&quot;;
  p3.country = &quot;이스트 블루 오이코트 왕국&quot;;
  p3.money = 360000000L;
  p3.group = &quot;밀짚모자 일당&quot;;
  p3.isDevilFruit = false;
  list.add(p3);

  // 해적4
  Pirate p4 = new Pirate();
  p4.name = &quot;우솝&quot;;
  p4.nickName = &quot;저격의 제왕&quot;;
  p4.gender = &#39;M&#39;;
  p4.birth = &quot;4월 1일&quot;;
  p4.age = 19;
  p4.height = 176;
  p4.hobby = null;
  p4.blood = &quot;S형 (O형)&quot;;
  p4.country = &quot;이스트 블루 시롭 마을&quot;;
  p4.money = 500000000L;
  p4.group = &quot;밀짚모자 일당&quot;;
  p4.isDevilFruit = false;
  list.add(p4);

  // 해적5
  Pirate p5 = new Pirate();
  p5.name = &quot;빈스모크 상디&quot;;
  p5.nickName = &quot;검은 다리&quot;;
  p5.gender = &#39;M&#39;;
  p5.birth = &quot;3월 2일&quot;;
  p5.age = 21;
  p5.height = 180;
  p5.hobby = null;
  p5.blood = &quot;Rh-S형 (Rh-O형)&quot;;
  p5.country = &quot;노스 블루 제르마 왕국&quot;;
  p5.money = 1032000000L;
  p5.group = &quot;밀짚모자 일당&quot;;
  p5.isDevilFruit = false;
  list.add(p5);

  // 해적6
  Pirate p6 = new Pirate();
  p6.name = &quot;토니토니 쵸파&quot;;
  p6.nickName = &quot;솜사탕광&quot;;
  p6.gender = &#39;M&#39;;
  p6.birth = &quot;12월 24일&quot;;
  p6.age = 17;
  p6.height = 90;
  p6.hobby = null;
  p6.blood = &quot;X형 (A형)&quot;;
  p6.country = &quot;위대한 항로 사쿠라 왕국(구 드럼 왕국)&quot;;
  p6.money = 1000L;
  p6.group = &quot;밀짚모자 일당&quot;;
  p6.isDevilFruit = true;
  list.add(p6);

  // 해적7
  Pirate p7 = new Pirate();
  p7.name = &quot;니코 로빈&quot;;
  p7.nickName = &quot;악마의 아이&quot;;
  p7.gender = &#39;F&#39;;
  p7.birth = &quot;2월 6일&quot;;
  p7.age = 30;
  p7.height = 188;
  p7.hobby = null;
  p7.blood = &quot;S형 (O형)&quot;;
  p7.country = &quot;웨스트 블루 오하라&quot;;
  p7.money = 930000000L;
  p7.group = &quot;밀짚모자 일당&quot;;
  p7.isDevilFruit = true;
  list.add(p7);

  // 해적8
  Pirate p8 = new Pirate();
  p8.name = &quot;커티 프람&quot;;
  p8.nickName = &quot;프랑키&quot;;
  p8.gender = &#39;M&#39;;
  p8.birth = &quot;3월 9일&quot;;
  p8.age = 36;
  p8.height = 240;
  p8.hobby = null;
  p8.blood = &quot;XF형 (AB형)&quot;;
  p8.country = &quot;사우스 블루&quot;;
  p8.money = 390000000L;
  p8.group = &quot;밀짚모자 일당&quot;;
  p8.isDevilFruit = false;
  list.add(p8);

  // 해적9
  Pirate p9 = new Pirate();
  p9.name = &quot;브룩&quot;;
  p9.nickName = &quot;소울 킹&quot;;
  p9.gender = &#39;M&#39;;
  p9.birth = &quot;4월 3일&quot;;
  p9.age = 90;
  p9.height = 277;
  p9.hobby = null;
  p9.blood = &quot;X형 (A형)&quot;;
  p9.country = &quot;웨스트 블루&quot;;
  p9.money = 383000000L;
  p9.group = &quot;밀짚모자 일당&quot;;
  p9.isDevilFruit = true;
  list.add(p9);

  // 해적10
  Pirate p10 = new Pirate();
  p10.name = &quot;징베&quot;;
  p10.nickName = &quot;바다의 협객&quot;;
  p10.gender = &#39;M&#39;;
  p10.birth = &quot;4월 2일&quot;;
  p10.age = 46;
  p10.height = 301;
  p10.hobby = null;
  p10.blood = &quot;F형 (B형)&quot;;
  p10.country = &quot;용국 왕국 어인가&quot;;
  p10.money = 1100000000L;
  p10.group = &quot;밀짚모자 일당&quot;;
  p10.isDevilFruit = false;
  list.add(p10);

  // 해적11
  Pirate p11 = new Pirate();
  p11.name = &quot;샹크스&quot;;
  p11.nickName = &quot;빨간 머리&quot;;
  p11.gender = &#39;M&#39;;
  p11.birth = &quot;3월 9일&quot;;
  p11.age = 39;
  p11.height = 199;
  p11.hobby = new ArrayList&lt;String&gt;();
  p11.hobby.add(&quot;방랑&quot;);
  p11.blood = &quot;XF형&quot;;
  p11.country = &quot;웨스트 블루 갓 밸리&quot;;
  p11.money = 4048900000L;
  p11.group = &quot;사황&quot;;
  p11.isDevilFruit = false;
  list.add(p11);

  // 해적12
  Pirate p12 = new Pirate();
  p12.name = &quot;마샬 D.티치&quot;;
  p12.nickName = &quot;검은 수염&quot;;
  p12.gender = &#39;M&#39;;
  p12.birth = &quot;8월 3일&quot;;
  p12.age = 40;
  p12.height = 344;
  p12.hobby = new ArrayList&lt;String&gt;();
  p12.hobby.add(&quot;도박(겜블링)&quot;);
  p12.hobby.add(&quot;역사 탐구&quot;);
  p12.blood = &quot;F형&quot;;
  p12.country = &quot;위대한 항로&quot;;
  p12.money = 3996000000L;
  p12.group = &quot;사황&quot;;
  p12.isDevilFruit = true;
  list.add(p12);

  // 해적13
  Pirate p13 = new Pirate();
  p13.name = &quot;마르코&quot;;
  p13.nickName = &quot;불사조&quot;;
  p13.gender = &#39;M&#39;;
  p13.birth = &quot;10월 5일&quot;;
  p13.age = 45;
  p13.height = 203;
  p13.hobby = new ArrayList&lt;String&gt;();
  p13.hobby.add(&quot;바의 코스터 수집&quot;);
  p13.blood = &quot;X형&quot;;
  p13.country = &quot;위대한 항로&quot;;
  p13.money = 1374000000L;
  p13.group = &quot;흰 수염 해적단&quot;;
  p13.isDevilFruit = true;
  list.add(p13);

  // 해적14
  Pirate p14 = new Pirate();
  p14.name = &quot;카타리나 데본&quot;;
  p14.nickName = &quot;초승달 헌터&quot;;
  p14.gender = &#39;F&#39;;
  p14.birth = &quot;3월 29일&quot;;
  p14.age = 36;
  p14.height = 361;
  p14.hobby = null;
  p14.blood = &quot;F형&quot;;
  p14.country = &quot;사우스 블루&quot;;
  p14.money = 0L;
  p14.group = &quot;검은 수염 해적단&quot;;
  p14.isDevilFruit = true;
  list.add(p14);

  // 해적15
  Pirate p15 = new Pirate();
  p15.name = &quot;샬롯 링링&quot;;
  p15.nickName = &quot;빅맘 &quot;;
  p15.gender = &#39;F&#39;;
  p15.birth = &quot;2월 15일&quot;;
  p15.age = 68;
  p15.height = 880;
  p15.hobby = new ArrayList&lt;String&gt;();
  p15.hobby.add(&quot;다과회, 진귀한 동물수집&quot;);
  p15.blood = &quot;X형&quot;;
  p15.country = &quot;위대한 항로&quot;;
  p15.money = 4388000000L;
  p15.group = &quot;빅 맘 해적단&quot;;
  p15.isDevilFruit = true;
  list.add(p15);

  // 해적16
  Pirate p16 = new Pirate();
  p16.name = &quot;크로커다일&quot;;
  p16.nickName = &quot;사막의 왕&quot;;
  p16.gender = &#39;M&#39;;
  p16.birth = &quot;9월 5일&quot;;
  p16.age = 46;
  p16.height = 253;
  p16.hobby = null;
  p16.blood = &quot;S&quot;;
  p16.country = &quot;위대한 항로&quot;;
  p16.money = 1965000000L;
  p16.group = &quot;크로스 길드&quot;;
  p16.isDevilFruit = true;
  list.add(p16);

  // 해적17
  Pirate p17 = new Pirate();
  p17.name = &quot;카이도&quot;;
  p17.nickName = &quot;백수&quot;;
  p17.gender = &#39;M&#39;;
  p17.birth = &quot;5월 1일&quot;;
  p17.age = 59;
  p17.height = 710;
  p17.hobby = null;
  p17.blood = &quot;F형&quot;;
  p17.country = &quot;위대한 항로 보드카 왕국&quot;;
  p17.money = 4611100000L;
  p17.group = &quot;백수 해적단&quot;;
  p17.isDevilFruit = true;
  list.add(p17);

  // 해적18
  Pirate p18 = new Pirate();
  p18.name = &quot;보아 행콕&quot;;
  p18.nickName = &quot;해적여제&quot;;
  p18.gender = &#39;F&#39;;
  p18.birth = &quot;9월 2일&quot;;
  p18.age = 31;
  p18.height = 191;
  p18.hobby = null;
  p18.blood = &quot;S형&quot;;
  p18.country = &quot;캄벨트 여인섬 아마존 릴리&quot;;
  p18.money = 1659000000L;
  p18.group = &quot;구사 해적단&quot;;
  p18.isDevilFruit = true;
  list.add(p18);

  // 해적19
  Pirate p19 = new Pirate();
  p19.name = &quot;피셔 타이거&quot;;
  p19.nickName = &quot;노예해방의 영웅&quot;;
  p19.gender = &#39;M&#39;;
  p19.birth = &quot;11월 5일&quot;;
  p19.age = 48;
  p19.height = 520;
  p19.hobby = null;
  p19.blood = &quot;Rh-S형&quot;;
  p19.country = &quot;용국 왕국 어인가&quot;;
  p19.money = 230000000L;
  p19.group = &quot;태양 해적단&quot;;
  p19.isDevilFruit = false;
  list.add(p19);

  // 해적20
  Pirate p20 = new Pirate();
  p20.name = &quot;유스타스 키드&quot;;
  p20.nickName = &quot;유스타스 &#39;캡틴&#39;키드&quot;;
  p20.gender = &#39;M&#39;;
  p20.birth = &quot;1월 10일&quot;;
  p20.age = 23;
  p20.height = 205;
  p20.hobby = new ArrayList&lt;String&gt;();
  p20.hobby.add(&quot;음악 감상&quot;);
  p20.hobby.add(&quot;무기 수집&quot;);
  p20.blood = &quot;F형&quot;;
  p20.country = &quot;사우스 블루&quot;;
  p20.money = 3000000000L;
  p20.group = &quot;최악의 세대&quot;;
  p20.isDevilFruit = true;
  list.add(p20);

  // 디버깅
  System.out.println(list.size() + &quot;&lt;-- list.size()&quot;);
</code></pre>
</li>
</ul>
<p>%&gt;
<!DOCTYPE html></p>
<html>
<head>
<meta charset="UTF-8">
<title>onepiece.jsp</title>
<style>
    table, th, td {
        border: 1px solid #808080;
    }
    table {
        border-collapse: collapse;
        text-align: center;
    }
    th {background-color: #D5D5D5;}
</style>
</head>
<body>
    <h1>등장인물 리스트</h1>
    <!-- 리스트 작성 -->
    <table>    
        <tr>
            <th>이름</th>
            <th>이명</th>
            <th>성별</th>
            <th>생일</th>
            <th>나이</th>
            <th>신장</th>
            <th>취미</th>
            <th>혈액형</th>
            <th>출생지</th>
            <th>현상금</th>
            <th>소속</th>
            <th>능력자</th>
        </tr>
    <%
        for(Pirate p : list) { 
        // list에 추가한 Pirate타입의 수만큼 tr(행)을 반복하여 출력한다 (행의 합 = 레코드셋)
    %>
            <tr>
                <td><%=p.name%></td>
                <td><%=p.nickName%></td>
                <td> <!-- 성별에 따라 이미지 출력 -->
    <%
                    if(p.gender == 'M') {
    %>
                        <img src="./image/man.png" width="50" height="50">
    <%                    
                    } else {
    %>
                        <img src="./image/woman.png" width="50" height="50">
    <%
                    }
    %>                    
                </td>
                <td><%=p.birth%></td>
                <td><%=p.age%>세</td>
                <td><%=p.height%>cm</td>
                <td>
                    <%
                        // hobby가 null이 아닌 경우에만 출력
                        if(p.hobby != null) {    
                            int cnt = 1; // cnt는 for문에서 사용되기 때문에 for문 밖에서 변수 선언
                            for(String h : p.hobby) {
                    %>
                                <%=h%>
                    <%
                                // cnt가 hobby수보다 작으면 쉼표 찍고 cnt는 1씩 증가
                                if(cnt<p.hobby.size()) {
                    %>
                                    ,
                    <%                
                                }
                                cnt = cnt + 1;
                            }
                        }
                    %>                
                </td>
                <td><%=p.blood%></td>
                <td><%=p.country%></td>
                <td>
                    <%
                        if(p.money!=0) {
                    %>
                            <%=p.money%>베리
                    <%                    
                        } else {
                    %>
                            &nbsp;
                    <%    
                        }
                    %>    
                </td>
                <td><%=p.group%></td>
                <td>
                    <%
                        if(p.isDevilFruit==true) {
                    %>
                            <img src="./image/devilfruit.png" width="50" height="50">
                    <%                    
                        } else {
                    %>
                            <img src="./image/no.png" width="50" height="50">
                    <%    
                        }
                    %>    
                </td>
            </tr>
    <%
        }
    %>
    </table>
</body>
</html>
```
### ✅필터링
* 필터링된 list 생성
```java
    // 검색조건에 따라 필터링된 list2를 생성
    ArrayList<Pirate> list2 = new ArrayList<Pirate>();

<pre><code>// 요청값 디버깅
    System.out.println(request.getParameter(&quot;gender&quot;));</code></pre><p>System.out.println(list2.size() + &quot;&lt;--list2.size&quot;);</p>
<pre><code>char gender = &#39; &#39;; // gender의 초기값 = 공백 // 페이지를 호출했을 때 첫 페이지
// gender가 경우의 수 3개 : 공백, M, F
// gender가 null이 아니거나 공백이 아닐 때
if(request.getParameter(&quot;gender&quot;) != null) {
    gender = request.getParameter(&quot;gender&quot;).charAt(0); // 요청값의 첫번째 문자를 gender변수에 넣는다
}
// gender &#39; &#39; or &#39;M&#39; or &#39;F&#39;
/*
if(gender == &#39; &#39;) {
    list2 = list;
} else if (gender ==&#39;M&#39;) {
    for(Pirate p : list) {
        if(p.gender == &#39;M&#39;)
            list2.add(p);
    }
} else { // gender = &#39;F&#39;
    for(Pirate p : list) {
        if(p.gender == &#39;F&#39;)
        list2.add(p);    
}
*/

    if(gender == &#39; &#39;) {
        list2 = list;
    } else {
        for(Pirate p : list) {
            if(p.gender == gender) {
                list2.add(p);
            }
        }
    }


// gender가 경우의 수가 4개인 경우
/* 
gender가 null이 아니거나 공백이 아닐 때
if(request.getParameter(&quot;gender&quot;) != null || 
        !request.getParameter(&quot;gender&quot;).equals(&quot;&quot;)) {
    gender = request.getParameter(&quot;gender&quot;).charAt(0);
}
*/</code></pre><pre><code>* select 폼 작성
```html
&lt;h1&gt;등장인물 리스트&lt;/h1&gt;

    &lt;!-- 필터 --&gt;
    &lt;form action=&quot;./onepiece.jsp&quot; method=&quot;post&quot;&gt; &lt;!-- action을 안적으면 자기자신 호출 --&gt;
        &lt;select name=&quot;gender&quot;&gt; &lt;!-- 경우의 수 3가지: null, M, F --&gt;
            &lt;!-- &lt;option value=&quot;&quot;&gt;:::성별선택:::&lt;/option&gt; --&gt; &lt;!-- 공백의 경우의 수 추가 --&gt;
            &lt;option value=&quot;M&quot;&gt;남자&lt;/option&gt;
            &lt;option value=&quot;F&quot;&gt;여자&lt;/option&gt;
        &lt;/select&gt;
        &lt;div&gt;
            &lt;button type=&quot;submit&quot;&gt;검색&lt;/button&gt;
        &lt;/div&gt;
    &lt;/form&gt;</code></pre><h3 id="✅부트스트랩">✅부트스트랩</h3>
<pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;!-- CSS적용 순서는 inline-&gt;internal-&gt;external(부트스트랩) --&gt;
&lt;!-- Latest compiled and minified CSS --&gt;
&lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;&gt;
&lt;!-- .min빼면 원래 파일 --&gt;
&lt;!-- Latest compiled JavaScript --&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;container-fluid&quot;&gt;
    &lt;table class=&quot;table table-striped&quot;&gt;
        &lt;thead&gt;
            &lt;tr&gt;
                &lt;th class=&quot;x&quot;&gt;이름&lt;/th&gt;
                &lt;th&gt;성별&lt;/th&gt;
                &lt;th&gt;나이&lt;/th&gt;
            &lt;/tr&gt;
        &lt;thead&gt;

        &lt;tbody&gt;
        &lt;%
            for(Person p : list) { // 군집 개별요소 : 군집 -&gt; list.size 만큼 반복
        %&gt;
                &lt;tr&gt;
                    &lt;td&gt;&lt;%=p.name%&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;%=p.gender%&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;%=p.age%&gt;&lt;/td&gt;
                &lt;/tr&gt;
        &lt;%
            }
        %&gt;
        &lt;/tbody&gt;
    &lt;/table&gt;

&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;col-sm-6&quot;&gt;
      &lt;h1&gt;첫번째 제목&lt;/h1&gt; &lt;!-- h1은 블록태그이지만 css적용으로 2단으로 나눠짐 --&gt;
  &lt;/div&gt;
  &lt;div class=&quot;col-sm-6&quot;&gt;
      &lt;h1&gt;두번째 제목&lt;/h1&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<hr>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>리스트는 어제도 만들고 오늘도 만들었지만 여전히 낯설다. 가장 중요한 것은 for문, if문, ArrayList를 잘 사용하는 것인데 처음이라 쉽지 않다. 그래도 계속 하다보면 익숙해지니까 포기하지 말자!</li>
<li>부트스트랩을 처음 사용해봤는데 역시! 전문가들의 손길이 닿으니 보여지는 부분에서 만족감이 크다!!! 디자인이나 미적인 부분에 약하고 CSS를 공부하고 오지 않아서 실습할 때마다 아쉬웠는데 앞으로는 부트스트랩을 적극적으로 활용할 것이다.</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 국비지원 7일차_2: 클래스, for문, foreach문, 리스트만들기]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-7%EC%9D%BC%EC%B0%A82</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-7%EC%9D%BC%EC%B0%A82</guid>
            <pubDate>Thu, 13 Apr 2023 06:03:15 GMT</pubDate>
            <description><![CDATA[<h3 id="✅클래스안에-선언된-메서드-호출하기">✅클래스안에 선언된 메서드 호출하기</h3>
<blockquote>
<p>클래스의 역할</p>
</blockquote>
<ol>
<li>사용자 정의 타입</li>
<li>메서드의 상자</li>
</ol>
<ul>
<li>데이터 타입 클래스<pre><code class="language-java">package good;
</code></pre>
</li>
</ul>
<p>public class Student { // 클래스: 사용자 정의 타입
    public int no;
    public int age;
    public String name;
    public char gender; 
}</p>
<pre><code>* 클래스 안에 선언된 메서드
```java
package good;

public class Function {
    // 일반 메서드
    public int add(int x, int y) { // x와 y는 매개변수
        int z = x + y;
        return z;
    }

    // static 메서드
    public static int minus(int x, int y) {
        int z = x - y;
        return z;
    }
}</code></pre><hr>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@ page import = &quot;good.Student&quot;%&gt;
&lt;%@ page import = &quot;good.Function&quot;%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;%
    //1. 클래스는 사용자정의 타입 
    Student s = null; 
    /* 
    String, Calendar 등은 API에서 제공하는 클래스
    다른 사람이 이미 만들어 놓은 클래스들 -&gt; 라이브러리
    라이브러리를 사용하는 방식 -&gt; API
    */
    s = new Student();
    /* 
    new 연산자
    1. 메모리확보
    2. 초기화
        no = 0; 
        age = 0;
        name = null;
        gender=&#39;&#39;; &lt;-없는 문자
     */

    s.no = 7;
    s.age = 28;
    s.name = &quot;홍길동&quot;;
    s.gender = &#39;남&#39;;
%&gt;
    &lt;div&gt;&lt;%=s.name%&gt;&lt;/div&gt;

&lt;%
    // 2. 클래스는 메서드의 상자
    Function f = null; 
    f = new Function();
    int result = f.add(1, 2); // 3
    int k = 7;
    result = f.add(k, 7/3); // f.add(7, 2) = 9

    int result2 = Function.minus(5, 2);
    // result = Function.add(5, 2); error
    // static 메소드는 호출할 때 클래스 이름을 붙인다

    // static 메서드의 예
    Math.random();
    /* 우리가 선언하지 않아도 이미 선언되어 있는 내장객체
    out.print(); 
    request.getParameter(&quot;&quot;);
    */
%&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="✅-배열-for문-foreach문">✅ 배열, for문, foreach문</h3>
<pre><code class="language-java">&lt;%
    // 배열 : 동일한 타입 여러개를 참조하는 참조 타입
    int[] a = null;
    a = new int[3]; // a[0]-&gt;0, a[1]-&gt;0, a[2]-&gt;0
    // 배열호출 : 참조변수[인덱스]
    a[0] = 7;
    a[1] = 2;
    a[2] =10;
    // a[3] =1; // 예외(exception)발생

    int[] b = new int[3];
    int[] c = new int[]{7, 9, 10};
    int[] d = {8, 10};
    int[] e = null;
    // e = {8, 10}; error
    out.print(a.length); // 인덱스의 길이 3
%&gt;
    &lt;br&gt;
&lt;%    
    int[] arr = {2,5,7,10}; // length 4
%&gt;
    &lt;div&gt;
        &lt;%=arr[0]%&gt;
        &lt;%=arr[1]%&gt;
        &lt;%=arr[2]%&gt;
        &lt;%=arr[3]%&gt;
    &lt;/div&gt;
&lt;%
    // for문 읽기 쓰기 가능 (배열을 직접적으로 변경 -&gt; 보안에 취약)
    for(int i=0; i&lt;arr.length; i+=1) { 
    // 배열의 길이가 변경될 수 있기 때문에 상수를 쓰기보다 변수를 이용한다
%&gt;
        &lt;%=arr[i]%&gt;
&lt;%
    }
%&gt;
    &lt;br&gt;
&lt;%
    // foreach문 읽기만 가능 (배열을 바꿀 수 없다)
    for(int n : arr) {
%&gt;
        &lt;%=n%&gt; &lt;!-- n이 변경되고 배열의 값은 그대로 --&gt;
&lt;%    
    }
%&gt;
    &lt;br&gt;
&lt;%
    // for문 읽기 쓰기 가능 (배열을 직접적으로 변경 -&gt; 보안에 취약)
    for(int i=0; i&lt;arr.length; i+=1) {
        arr[i] = arr[i]*10;
    }
%&gt;</code></pre>
<h3 id="✅swap과-로또만들기">✅swap과 로또만들기</h3>
<ul>
<li><p>Swap</p>
<pre><code class="language-java">&lt;%
  int x = 1;
  int y = 2;
  int temp = 0;

  temp = y; 
  y = x;
  x = temp;
%&gt;</code></pre>
</li>
<li><p>로또만들기</p>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%
  // 1. 45개의 공을 만든다
  int[] ball = new int[45]; // 초기화 0, 0, ... , 0
  // 1~45 값을 대입
  for(int i=0; i&lt;ball.length; i+=1) {
      ball[i] = i+1;
  }
  // 디버깅 코드(변수의 값이 원하는대로 제대로 들어갔는지 확인하는 코드)
  for(int n : ball) {
      System.out.print(n+&quot;,&quot;); // println -&gt; 줄바꿈 포함
  }
  System.out.println(); // 콘솔줄바꿈

  // 2. 공을 섞는다
  // shuffle
  for(int i=0; i&lt;100000; i+=1) {
      int targetIdx = (int)(Math.random() * 45); // 0~44까지 랜덤숫자
      int temp = ball[0];
      ball[0] = ball[targetIdx];
      ball[targetIdx] = temp; // swap을 10만번 반복
  }

  // 디버깅 코드(변수의 값이 원하는대로 제대로 들어갔는지 확인하는 코드)
      for(int n : ball) {
          System.out.print(n+&quot;,&quot;); // println -&gt; 줄바꿈 포함
      }
</code></pre>
</li>
</ul>
<p>%&gt;
<!DOCTYPE html></p>
<html>
<head>
<meta charset="UTF-8">
<title>Lotto</title>
</head>
<body>
    <h1>로또번호</h1>
    <%
        // 3. 6개의 공을 뽑는다
        for(int i=0; i<6; i+=1) {
    %>
            <%=ball[i]%>&nbsp;
    <%
        }
    %>
</body>
</html>
```
### ✅리스트 만들기
![](https://velog.velcdn.com/images/jin_0/post/ffeab372-15af-4b8e-b41c-3f3766d2efb9/image.png)

<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@ page import = &quot;good.Member&quot; %&gt;
&lt;%@ page import = &quot;java.util.Calendar&quot; %&gt;
&lt;%
    // 데이터 초기화

    Member[] list = new Member[2]; // null, null로 초기화
    list[0] = new Member(); 
    list[0].name = &quot;루피&quot;;
    list[0].birthYear = 2005;
    list[0].gender = &quot;여&quot;;
    list[0].major = false;

    list[1] = new Member(); 
    list[1].name = &quot;뽀로로&quot;;
    list[1].birthYear = 2006;
    list[1].gender = &quot;남&quot;;
    list[1].major = true;
 %&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;memberList.jsp&lt;/title&gt;
&lt;style&gt;
    table, th, td {
        border: 1px solid #404040; 
        border-collapse: collapse;
        text-align: center;
        }
    table {width: 40%;}
    th {background-color: #D5D5D5;}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;학생목록&lt;/h1&gt;
    &lt;div&gt;전체 &lt;%=list.length%&gt;명&lt;/div&gt;
    &lt;table&gt;
        &lt;tr&gt;
            &lt;th&gt;이름&lt;/th&gt;
            &lt;th&gt;나이&lt;/th&gt;
            &lt;th&gt;성별&lt;br&gt;(아이콘)&lt;/th&gt;
            &lt;th&gt;전공유무&lt;br&gt;(전공/비전공)&lt;/th&gt;
        &lt;/tr&gt;
        &lt;%
            // 현재년도
            Calendar today = Calendar.getInstance(); 
            int todayYear = today.get(Calendar.YEAR);

            // 학생목록 출력
            for(Member m : list) {
        %&gt;
                &lt;tr&gt;
                    &lt;td&gt;&lt;%=m.name%&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;%=todayYear - m.birthYear +1%&gt;&lt;/td&gt; &lt;!-- 한국나이 = 현재년도-태어난년도+1 --&gt;
                    &lt;td&gt;
                    &lt;%
                        if(m.gender.equals(&quot;남&quot;)) {
                    %&gt;
                        &amp;#128104; &lt;!-- 남자 아이콘 --&gt;
                    &lt;%
                        } else {
                    %&gt;
                        &amp;#128105; &lt;!-- 여자 아이콘 --&gt;
                    &lt;%
                        }
                    %&gt;
                    &lt;/td&gt;
                    &lt;td&gt;
                    &lt;%
                        if(m.major==false) {
                    %&gt;
                        비전공
                    &lt;%
                        } else {
                    %&gt;
                        전공
                    &lt;%
                        }
                    %&gt;
                    &lt;/td&gt;
                &lt;/tr&gt;
        &lt;%        
            }
        %&gt;
    &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="💪-느낀점">💪 느낀점</h3>
<ul>
<li>복습의 중요성!
리스트 만들기 중에서 나이는 현재시간 기준으로 계산해야 하므로 <code>calendar</code>클래스를 사용해야 한다. </li>
<li>배열과 for문이 함께 나오면 코드 한줄 한줄 더 집중해서 보자</li>
<li>어제보다는 HTML과 Java가 번갈아서 나오는 것에 익숙해졌다. &quot;어려운 것이 아니라 익숙치 않은 것일 뿐&quot;이라는 말을 기억하자!</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 국비지원 7일차_1: 구구단과 달력만들기]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-7%EC%9D%BC%EC%B0%A81</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-7%EC%9D%BC%EC%B0%A81</guid>
            <pubDate>Thu, 13 Apr 2023 01:52:56 GMT</pubDate>
            <description><![CDATA[<p>구디아카데미 7일차.
오늘 시작은 어제 만들었던 구구단의 응용버전과 if문, for문을 활용한 달력만들기이다.</p>
<h3 id="✅구구단-배경색-넣기-❗코어알고리즘-변경-추가-없이">✅구구단 배경색 넣기 (❗코어알고리즘 변경, 추가 없이)</h3>
<p><img src="https://velog.velcdn.com/images/jin_0/post/5a180860-dd1c-42eb-b4a8-85a3679591f6/image.png" alt=""></p>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;무지개 구구단&lt;/title&gt;
&lt;style&gt;
    table, th, td {
        border: 1px solid #404040;
        text-align: center;
    }
    table {border-collapse: collapse;}
    .red {background-color: #FFA7A7;}
    .orange {background-color: #FFC19E;}
    .yellow {background-color: #FFE08C;}
    .green {background-color: #B7F0B1;}
    .blue {background-color: #B2EBF4;}
    .navy {background-color: #B2CCFF;}
    .purple {background-color: #D1B2FF;}
    .gray {background-color: #D5D5D5;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;구구단&lt;/h1&gt;
    &lt;table&gt;
        &lt;%
            // tr * 10 = 10행
            for(int i=0; i&lt;10 ; i=i+1) {
        %&gt;
                &lt;tr&gt;
                    &lt;%
                        // td * 9 = 9열
                        for(int dan=2; dan&lt;10; dan=dan+1) { 
                        // 코어알고리즘(dan=0; dan&lt;8; dan=dan+1)은 변경하지 않는것이 좋지만 연습을 위해 초기화 숫자를 dan=2로 변경

                            // dan숫자에 따라 클래스의 이름이 바뀐다
                            String color = null;
                            if(dan==2) {
                                color=&quot;red&quot;;
                            } else if (dan==3) {
                                color=&quot;orange&quot;;
                            } else if (dan==4) {
                                color=&quot;yellow&quot;;
                            } else if (dan==5) {
                                color=&quot;green&quot;;
                            } else if (dan==6) {
                                color=&quot;blue&quot;;
                            } else if (dan==7) {
                                color=&quot;navy&quot;;
                            } else if (dan==8) {
                                color=&quot;purple&quot;;
                            } else if (dan==9) {
                                color=&quot;gray&quot;;
                            }

                            // 첫번째 행은 단수제목, 나머지는 구구단 출력
                            if(i==0) {
                    %&gt;
                                &lt;th class=&quot;&lt;%=color%&gt;&quot;&gt;&lt;%=dan%&gt; 단&lt;/th&gt;
                    &lt;%    
                            } else {
                    %&gt;
                                &lt;td class=&quot;&lt;%=color%&gt;&quot;&gt;&lt;%=dan%&gt; * &lt;%=i%&gt; = &lt;%=dan*i%&gt;&lt;/td&gt;
                    &lt;%
                            }
                        }
                    %&gt;
                &lt;/tr&gt;
        &lt;%
            }
        %&gt;
    &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="✅-구구단-출력">✅ 구구단 출력</h3>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;guguForm.jsp&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;구구단 요청&lt;/h1&gt;
    &lt;form action=&quot;./guguAction.jsp&quot; method=&quot;post&quot;&gt;
        &lt;div&gt;
            &lt;select name=&quot;dan&quot;&gt;
                &lt;%
                    for(int i=2; i&lt;10; i=i+1) {
                %&gt;
                        &lt;option value=&quot;&lt;%=i%&gt;&quot;&gt;&lt;%=i%&gt;단&lt;/option&gt;
                &lt;%
                    }
                %&gt;
            &lt;/select&gt;
        &lt;/div&gt;
        &lt;div&gt;
            &lt;button type=&quot;submit&quot;&gt;구구단 출력&lt;/button&gt;
        &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%
    request.setCharacterEncoding(&quot;utf-8&quot;); // 한글을 받지 않아도 적어주는 것이 좋다
    int dan = Integer.parseInt(request.getParameter(&quot;dan&quot;));
%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;guguAction.jsp&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;%
    for(int i=1; i&lt;10; i=i+1) {
%&gt;
        &lt;div&gt;&lt;%=dan%&gt; * &lt;%=i%&gt; = &lt;%=dan*i%&gt;&lt;/div&gt;
&lt;%
    }
%&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="✅달력만들기">✅달력만들기</h3>
<p><img src="https://velog.velcdn.com/images/jin_0/post/3e2daddc-88bf-4f6d-8127-0c66656480b5/image.png" alt=""></p>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;23년 4월 달력&lt;/title&gt;
&lt;style&gt;
    table, th, td {border: 1px solid gray;}
    table {border-collapse: collapse; width: 90%;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;2023.4&lt;/h1&gt;
    &lt;table&gt; &lt;!-- 요일표시 테이블 --&gt;
        &lt;tr&gt;
            &lt;th&gt;일&lt;/th&gt;
            &lt;th&gt;월&lt;/th&gt;
            &lt;th&gt;화&lt;/th&gt;
            &lt;th&gt;수&lt;/th&gt;
            &lt;th&gt;목&lt;/th&gt;
            &lt;th&gt;금&lt;/th&gt;
            &lt;th&gt;토&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/table&gt; &lt;!-- 날짜표시 테이블 --&gt;
    &lt;table&gt; 
        &lt;tr&gt;
        &lt;%
            // 날짜의 최소값~최대값 범위설정
            int minDate = 1; 
            int maxDate = 30;

            // 7*6=42개의 셀 반복
            for(int i=0; i&lt;42; i+=1) { // i+=1 --&gt; i=i+1
                if(i%7==0) { // 7의 배수에서 행 바꿈
        %&gt;
                    &lt;/tr&gt;&lt;tr&gt;
        &lt;%
                }

                if((i-5)&gt;=minDate &amp;&amp; (i-5)&lt;=maxDate) { // 날짜가 1~30일 사이이면 표시 나머지 공백
                    if(i%7==0) { // 일요일에만 글자색을 빨간색으로 설정 (만약 토요일이라면 i%7==6)
        %&gt;            
                        &lt;td style=&quot;color:#FF0000;&quot;&gt;&lt;%=i-5%&gt;&lt;/td&gt;
        &lt;%
                    } else {
        %&gt;
                        &lt;td&gt;&lt;%=i-5%&gt;&lt;/td&gt;
        &lt;%        
                    }
                } else { 
        %&gt;
                    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;%
                }
            }
        %&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 국비지원 6일차_2: 구구단]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-6%EC%9D%BC%EC%B0%A82</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-6%EC%9D%BC%EC%B0%A82</guid>
            <pubDate>Wed, 12 Apr 2023 08:42:21 GMT</pubDate>
            <description><![CDATA[<p>구구단...
역시 문법과 실습의 체감 난이도의 차이는 상당하다;;;</p>
<h3 id="✅-구구단">✅ 구구단</h3>
<pre><code class="language-java">&lt;%

    // out.print(&quot;2*&quot;+1); // out.print(&quot;2*&quot;+&quot;1&quot;); 출력:2*1

    out.print(2 + &quot;*&quot; + 1 + &quot;=&quot; + (2*1) + &quot; &quot;);
    out.print(2 + &quot;*&quot; + 2 + &quot;=&quot; + (2*2) + &quot; &quot;);
    out.print(2 + &quot;*&quot; + 3 + &quot;=&quot; + (2*3) + &quot; &quot;);
    out.print(2 + &quot;*&quot; + 4 + &quot;=&quot; + (2*4) + &quot; &quot;);
    out.print(2 + &quot;*&quot; + 5 + &quot;=&quot; + (2*5) + &quot; &quot;);
    out.print(2 + &quot;*&quot; + 6 + &quot;=&quot; + (2*6) + &quot; &quot;);
    out.print(2 + &quot;*&quot; + 7 + &quot;=&quot; + (2*7) + &quot; &quot;);
    out.print(2 + &quot;*&quot; + 8 + &quot;=&quot; + (2*8) + &quot; &quot;);
    out.print(2 + &quot;*&quot; + 9 + &quot;=&quot; + (2*9) + &quot; &quot;);
%&gt;
&lt;br&gt;
    &lt;h1&gt;구구단(가로)&lt;/h1&gt; &lt;!-- 패턴은 가로로 찾아야한다! --&gt;
    &lt;%
        for(int dan=2; dan&lt;10; dan=dan+1) { //8번
            for(int i=1; i&lt;10; i=i+1) { //9번
                out.print(dan + &quot;*&quot; + i + &quot;=&quot; + (dan*i) + &quot; &quot;);
            }
    %&gt;
        &lt;br&gt;
    &lt;%
        }
    %&gt;
        &lt;h1&gt;구구단(세로)&lt;/h1&gt;
    &lt;%
        for(int i=1; i&lt;10; i=i+1) {
            for(int dan=2; dan&lt;10; dan=dan+1) {
                out.print(dan + &quot;*&quot; + i + &quot;=&quot; + (dan*i) + &quot; &quot;);
            }
    %&gt;
    &lt;br&gt;
    &lt;%
        }
    %&gt;</code></pre>
<h3 id="⌨-구구단-테이블-만들기">⌨ 구구단 테이블 만들기</h3>
<p><img src="https://velog.velcdn.com/images/jin_0/post/b64ffe74-abaf-4f05-b6ec-47b1e2f07cf9/image.png" alt=""></p>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot;
    pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;style&gt;
    table, td {
        border: 1px solid #000000;
        border-collapse: collapse;
        text-align: center;
    }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;구구단(세로)&lt;/h1&gt;
    &lt;table&gt;
        &lt;!-- 1행 --&gt;
        &lt;tr&gt; &lt;!-- 구구단 이름--&gt;
        &lt;%
            for(int dan=2; dan&lt;10; dan=dan+1) {
        %&gt;
                &lt;td&gt; &lt;!-- 2단~8단 --&gt;
                &lt;%=dan%&gt;단
                &lt;/td&gt;
        &lt;%
            }
        %&gt;
        &lt;/tr&gt;

        &lt;!-- 2행~10행 --&gt;
        &lt;%
            for(int i=1; i&lt;10; i=i+1) {
        %&gt;
                &lt;tr&gt; &lt;!-- i가 1~9까지 반복하여 총 9행이 만들어진다--&gt;
        &lt;%
                    for(int dan=2; dan&lt;10; dan=dan+1) {
        %&gt;
                        &lt;td&gt; &lt;!-- dan이 2~9까지 반복하여 총 8열이 만들어진다 --&gt;
        &lt;%
                            out.print(dan + &quot;*&quot; + i + &quot;=&quot; + (dan*i) + &quot; &quot;);
        %&gt;
                        &lt;/td&gt;
        &lt;%
                    }
        %&gt;
                &lt;/tr&gt;
        &lt;%
            }
        %&gt;
    &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="💪느낀점">💪느낀점</h3>
<ul>
<li>반복문을 새롭게 배웠는데 쉽지 않다. 특히 구구단에 테이블을 씌운 것과 같이 html과 함께 쓰이는 경우 더 헷갈린다. 앞으로 수업시간에 반복문을 사용하게 되는 경우 더 집중해서 연습할 것이다.</li>
<li>주석을 다는 것을 자꾸 잊는다. 나중에 스스로 복습하고 이해하려면 주석을 꼼꼼히 쓰는 연습을 해야겠다. 내 언어로 직관적이고 간결하게 적을 수 있더록 놓치지 말자!</li>
<li>아직 css에 대한 지식이 많지 않아 원하는 스타일을 구현하지 못하니 아쉬운 마음이 계속 든다. 그래도 조급해하지 말고 중요한 자바 문법을 정확히 사용할 수 있도록 연습하자.</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 6일차_1: 참조타입, 클래스만들기, 조건문, 반복문]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-6%EC%9D%BC%EC%B0%A81</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-6%EC%9D%BC%EC%B0%A81</guid>
            <pubDate>Wed, 12 Apr 2023 03:00:16 GMT</pubDate>
            <description><![CDATA[<p>구디아카데미의 6일차가 지났다.
오늘부터는 과정 시작 전에 제대로 예습하지 못한 부분들이라 굉장히 새로웠다.</p>
<h3 id="✅참조타입-맛보기">✅참조타입 맛보기</h3>
<pre><code class="language-java">// 기본타입(8개) : 정수(byte, short, int, long), 실수(float, double), boolean, char
// 참조타입(?) : String, 배열, class

    String name = new String(&quot;지니&quot;); // new연산자는 참조의 데이터를 저장하는 공간을 생성하는 연산자(생성자)
    // String name = &quot;지니&quot;; // 문자열상수를 사용하는 방법

    out.print(name); // 출력 : 지니 → String은 다른 참조타입과 달리 데이터가 바로 출력된다
    out.print(name.hashCode()); // 출력 : 1646856

    // 배열 : 같은 타입의 변수를 여러개
    int[] arr = null; // null : 아무것도 아니다
    arr = new int[3]; // 
    out.print(arr); // 출력: [I@113d37b1 : int배열 @(구분자) 데이터위치
    arr[0] = 7; // . []는 참조연산자
    // [0] = 7; // 다른 배열을 만들면 똑같이 0이 있기 때문에 사용 불가
    arr[1] = 6;
    arr[2] = 3;

    out.print(arr[0]); // 7
    out.print(arr[1]); // 6
    out.print(arr[2]); // 3</code></pre>
<hr>
<h3 id="✅클래스-만들기">✅클래스 만들기</h3>
<pre><code class="language-java">    package gdj66; // package이름은 절대 대문자를 적지 않는다

// class이름은 대문자로 시작한다 (ex. JavaClass)
    public class Person {
    public int no; // public : 오픈되어있음, protected : 보안
    public int age;
    public boolean married; 
}</code></pre>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot;
 pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@ page import=&quot;java.lang.*&quot;%&gt; &lt;!-- import는 자바문법이 아니라 단축표현에 불과하다 --&gt;
&lt;%@ page import=&quot;gdj66.Person&quot;%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;%
    Person p;
    p = new Person(); // gdj66.Person()는 생성자메소드, 항상 클래스 이름과 동일하다
    p.no = 1;
    p.age = 24;
    p.married = false;

    Person kyh; // import를 사용: 클래스 이름을 줄여 gdj66.Person 대신 Person사용 가능
    kyh = new Person(); 
    kyh.no = 1;
    kyh.age = 29;
    kyh.married = false;

    Person ksj;
    ksj = new Person(); 
    ksj.no = 2;
    ksj.age = 30;
    ksj.married = false;

    out.print(p); // 참조값 출력)
// 추상화의 결과 : 데이터타입
%&gt;
    &lt;div&gt;번호 : &lt;%=p.no%&gt;&lt;/div&gt;
    &lt;div&gt;나이 : &lt;%=p.age%&gt;&lt;/div&gt;
    &lt;div&gt;결혼유무 : &lt;%=p.married%&gt;&lt;/div&gt;

    &lt;h2&gt;KYH&lt;/h2&gt;
    &lt;div&gt;번호 : &lt;%=kyh.no%&gt;&lt;/div&gt;
    &lt;div&gt;나이 : &lt;%=kyh.age%&gt;&lt;/div&gt;
    &lt;div&gt;결혼유무 : &lt;%=kyh.married%&gt;&lt;/div&gt;

    &lt;h2&gt;KSJ&lt;/h2&gt;
    &lt;div&gt;번호 : &lt;%=ksj.no%&gt;&lt;/div&gt;
    &lt;div&gt;나이 : &lt;%=ksj.age%&gt;&lt;/div&gt;
    &lt;div&gt;결혼유무 : &lt;%=ksj.married%&gt;&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="⌨주민번호로-나이-성별-분석하기">⌨주민번호로 나이, 성별 분석하기</h3>
<p><img src="https://velog.velcdn.com/images/jin_0/post/42cf565d-2390-45de-946d-0e43d7c8b4ae/image.png" alt="">
<img src="https://velog.velcdn.com/images/jin_0/post/6ed7f39f-42fa-4a56-b280-cd76c4c3cd05/image.png" alt=""></p>
<pre><code class="language-java">&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot;
    pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@ page import = &quot;java.util.Calendar&quot; %&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;%
    // 1. 요청처리
    String sn = request.getParameter(&quot;sn1&quot;) + request.getParameter(&quot;sn2&quot;);
    // 9012251234567
    // 7(인덱스6)번째 문자(열)를 뽑아서 숫자로 변경
    String s7 = sn.substring(6, 7); 
    int gender = Integer.parseInt(s7);

    // 2. 성별
    String sGender = null; // if 짝수 홀수
    if(gender%2==1) {
        sGender = &quot;남성&quot;;
    } else {
        sGender = &quot;여성&quot;;
    }

    // 3. 나이
    String preYear = &quot;null&quot;;
    if(gender==0 || gender==9 ) {
        preYear = &quot;18&quot;;
    } else if (gender == 1 || gender == 2 || gender == 5 || gender == 6) {
        preYear = &quot;19&quot;;
    } else {
        preYear = &quot;20&quot;;
    }

    String year = preYear + sn.substring(0, 2);
    int birthYear = Integer.parseInt(year);

    // 오늘 날짜 정보를 반화하는 클래스 java.lang.Calendar
    Calendar today = Calendar.getInstance(); 
    // today에서 오늘 년도만 추출
    int todayYear = today.get(Calendar.YEAR); 

    int age = todayYear - birthYear;
%&gt;
    성별 : &lt;%=sGender %&gt;&lt;br&gt;
    나이 : &lt;%=age %&gt;세
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<hr>
<h3 id="✅-아직은-몰라도-되는">✅ 아직은 몰라도 되는...</h3>
<h4 id="❗-변수-생명주기">❗ 변수 생명주기</h4>
<pre><code class="language-java">// 변수 생명주기(variable scope)
    // 1. 변수 선언 후 사용 가능
    // out.print(x); // 변수 x가 선언되기 전이라 error
    int x = 1;
    out.print(x);

    // 2. 자바언어의 변수 생명주기는 블록{}
    {
        int a = 2;
        a = 7;
        out.print(a);
    }
    // a = 10; // error
    int b = 3;
    {
        b = 5;
        out.print(b);
        int c = 6;
        {
            out.print(b);
            out.print(c);
            int d = 9;
        }
        // out.print(d); // error
    }</code></pre>
<h4 id="❗-radio-select-값-넘겨받기">❗ radio, select 값 넘겨받기</h4>
<p><img src="https://velog.velcdn.com/images/jin_0/post/b2975258-06ca-401f-81d0-5d968657a0a0/image.png" alt="">
<img src="https://velog.velcdn.com/images/jin_0/post/e840e5f3-6d82-4217-9dd9-a1914597094a/image.png" alt=""></p>
<pre><code class="language-java">&lt;%
    request.setCharacterEncoding(&quot;utf-8&quot;); // void: 반환값이 없다
    String gender = request.getParameter(&quot;gender&quot;);
    String married = request.getParameter(&quot;married&quot;);
%&gt;
    &lt;div&gt;
    성별
        &lt;%
            if(gender.equals(&quot;남&quot;)) {
            // radio에서 남이 선택된 상태
        %&gt;
                &lt;input type=&quot;radio&quot; value=&quot;남&quot; name=&quot;gender&quot; checked=&quot;checked&quot;&gt;남
                &lt;input type=&quot;radio&quot; value=&quot;여&quot; name=&quot;gender&quot;&gt;여
        &lt;%
        } else {
            // radio에서 여가 선택된 상태
        %&gt;
                &lt;input type=&quot;radio&quot; value=&quot;남&quot; name=&quot;gender&quot;&gt;남
                &lt;input type=&quot;radio&quot; value=&quot;여&quot; name=&quot;gender&quot; checked=&quot;checked&quot;&gt;여
        &lt;%
        }
        %&gt;

    &lt;/div&gt;
    &lt;div&gt;
        &lt;select name=&quot;married&quot;&gt;
            &lt;%
                if(married.equals(&quot;미혼&quot;)) {
                // select에서 미혼이 선택된 상태
            %&gt;
                &lt;option value=&quot;미혼&quot; selected=&quot;selected&quot;&gt;미혼&lt;/option&gt;
                &lt;option value=&quot;기혼&quot;&gt;기혼&lt;/option&gt;
            &lt;%
            } else {
                // select에서 기혼이 선택된 상태
            %&gt;
                &lt;option value=&quot;미혼&quot;&gt;미혼&lt;/option&gt;
                &lt;option value=&quot;기혼&quot; selected=&quot;selected&quot;&gt;기혼&lt;/option&gt;
            &lt;%
            }
            %&gt;
        &lt;/select&gt;
    &lt;/div&gt;
</code></pre>
<h3 id="✅조건문">✅조건문</h3>
<pre><code class="language-java">&lt;%
    // 1. 값분기
    int score = 80;
    if(score==100) {
        out.print(&quot;A&quot;);
    } else if(score==90) {
        out.print(&quot;B&quot;);
    } else if(score==80) {
        out.print(&quot;C&quot;);
    } else {
        out.print(&quot;D&quot;);
    }
%&gt;
&lt;br&gt;
&lt;%    
    switch(score) { 
    case 100:
        out.print(&quot;A&quot;);
        break; // break가 없으면 아래 조건도 만족하므로 ABCD모두 출력된다
    case 90:
        out.print(&quot;B&quot;);
        break;
    case 80:
        out.print(&quot;C&quot;);
        break;
    default:
        out.print(&quot;D&quot;);
    }
%&gt;
&lt;br&gt;
&lt;%
    // 2. 범위분기
    int score2 = 80;
    if(score2==100) {
        out.print(&quot;A&quot;);
    } else if(score2&gt;=90) {
        out.print(&quot;B&quot;);
    } else if(score2&gt;=80) {
        out.print(&quot;C&quot;);
    } else {
        out.print(&quot;D&quot;);
    }

    // switch문으로 범위분기를 구현하는 것은 거의 불가능하다(만약 하려면 모든 case를 작성해야함)
%&gt;</code></pre>
<h3 id="✅반복문">✅반복문</h3>
<pre><code class="language-java">&lt;%
    // 반복문
    int x = 0;
    while(x &lt; 5) {
        out.print(&quot;hello&quot;);
        x = x+1;
    }
    // hello가 5번 출력
%&gt;
    &lt;br&gt;
&lt;%
    for(int i=0; i&lt;5; i=i+1) { // i는 블록안에서 생성된 지역변수와 같다 -&gt; 블록을 나가면 i 쓸 수 있다
        out.print(&quot;hi&quot;);
    }
    // hi가 5번 출력
%&gt;
    &lt;br&gt;
&lt;%
    // 1부터 10까지의 합
    int n = 1;
    int sum = 0;
    for(int i=0; i&lt;10; i=i+1) {
        sum = sum + n;
        n = n + 1;
    }
    out.print(sum);
%&gt;
    &lt;br&gt;
&lt;%
    // 1부터 10까지의 합
    int sum2 = 0;
    for(int i=1; i&lt;11; i=i+1) {
        sum2 = sum2 + i;
    }
    out.print(sum);
%&gt;
    &lt;br&gt;
&lt;%
    // 1부터 10까지의 짝수의 합
    int sum3 = 0;
    for(int i=1; i&lt;11; i=i+1) { // ++i, i++, i+=1
        if(i%2==0) {
        sum3 = sum3 + i;
        }
    }
    out.print(sum3);
%&gt;</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 5일차:  String타입, if문]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-5%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-5%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Tue, 11 Apr 2023 11:40:04 GMT</pubDate>
            <description><![CDATA[<p>구디아카데미에서의 5일차가 지났다.
오늘은 자바의 데이터 타입 중 참조타입 String과 if를 이용한 조건문을 연습하였다.</p>
<h3 id="✅string타입을-int타입으로-변경하기">✅String타입을 int타입으로 변경하기</h3>
<pre><code class="language-java">&lt;%
    // 요청값(parameter value) 처리
    String x = request.getParameter(&quot;x&quot;);
    String y = request.getParameter(&quot;y&quot;);
    String z = x+y;

    int a = Integer.parseInt(x);
    int b = Integer.parseInt(y);
    int c = a+b;
%&gt;</code></pre>
<hr>
<h3 id="✅if문">✅if문</h3>
<blockquote>
<p>코드는 위에서 아래로 순차적으로 실행되는데 제어문을 이용하여 조건분기하거나 반복하는 코드를 작성할 수 있다.
조건문: <em>if</em>, switch
반복문: <em>for</em>, while</p>
</blockquote>
<pre><code class="language-java">&lt;%
    /*
    if(bool값) { **bool값: &quot;true&quot; or &quot;false&quot;

    }

    if(){

    }
    else {

    }

    if() {

    } else if() {

    } else if() {

    }

    if() {

    } else if() {

    } else if() {

    } else {

    }
    */

    int x = 7;
    int last = 7%2;
    if(last == 0) {
        out.print(&quot;짝수&quot;);
    } else {
        out.print(&quot;홀수&quot;);
    }
%&gt;</code></pre>
<h3 id="⌨-나이와-성별">⌨ 나이와 성별</h3>
<pre><code class="language-java">&lt;%
    // 요청값 처리
    String name = request.getParameter(&quot;name&quot;);

    int currentYear = 2023;

    String year = request.getParameter(&quot;year&quot;);
    int numYear = Integer.parseInt(year);

    // 한번에 구현하는것도 가능: 변수를 새롭게 지정할 필요가 없다.
    int sn7 = Integer.parseInt(request.getParameter(&quot;sn7&quot;));

    int age = currentYear - numYear;
    String gender = null;
    if(sn7 % 2 == 0) {
        gender = &quot;여&quot;;
    } else {
        gender = &quot;남&quot;;
    }
%&gt;</code></pre>
<pre><code class="language-html">    &lt;!-- 출력내용 --&gt;
    &lt;div&gt;&lt;%=name%&gt;님(&lt;%=age%&gt;)은 &lt;%=gender%&gt;입니다&lt;/div&gt;</code></pre>
<h3 id="⌨-주사위-던지기">⌨ 주사위 던지기</h3>
<pre><code class="language-java">&lt;%
    int d1 = 0; // 1~6, 0은 초기값, 참조타입은 null로 초기화
    int d2 = 0; // 1~6

    //double d = Math.random(); d는 0.000...~0.999...의 실수이다
    d1 = (int)(Math.random() * 6)+1;
    d2 = (int)(Math.random() * 6)+1;

    int sum = d1+d2;
%&gt;
    &lt;div&gt;
        &lt;%
            if(d1 == 1) {
        %&gt;
                &lt;img src=&quot;./img/one.jpg&quot;  width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%        
            } else if(d1 == 2) {
        %&gt;
                &lt;img src=&quot;./img/two.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%        
            } else if(d1 == 3) {
        %&gt;
                &lt;img src=&quot;./img/three.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%        
            } else if(d1 == 4) {
        %&gt;
                &lt;img src=&quot;./img/four.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%                
            } else if(d1 == 5) {
        %&gt;
                &lt;img src=&quot;./img/five.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%        
            } else {
        %&gt;
                &lt;img src=&quot;./img/six.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%
            }
        %&gt;

        &lt;%
            // 2번째 주사위
            if(d2 == 1) {
        %&gt;
                &lt;img src=&quot;./img/one.jpg&quot;  width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%        
            } else if(d2 == 2) {
        %&gt;
                &lt;img src=&quot;./img/two.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%        
            } else if(d2 == 3) {
        %&gt;
                &lt;img src=&quot;./img/three.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%        
            } else if(d2 == 4) {
        %&gt;
                &lt;img src=&quot;./img/four.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%                
            } else if(d2 == 5) {
        %&gt;
                &lt;img src=&quot;./img/five.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%        
            } else {
        %&gt;
                &lt;img src=&quot;./img/six.jpg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
        &lt;%
            }
        %&gt;
        &lt;!-- CSS를 이용한 이미지크기 방법도 생각해보기 ---&gt;
    &lt;/div&gt;
    &lt;div&gt;주사위 결과 : &lt;%=sum%&gt;&lt;/div&gt;</code></pre>
<h3 id="⌨-객관식-온라인-시험의-정오표와-점수">⌨ 객관식 온라인 시험의 정오표와 점수</h3>
<pre><code class="language-java">&lt;%
    String name = request.getParameter(&quot;name&quot;);

    //작성된 답안 변수
    int question1 = Integer.parseInt(request.getParameter(&quot;one&quot;));
    int question2 = Integer.parseInt(request.getParameter(&quot;two&quot;));
    int question3 = Integer.parseInt(request.getParameter(&quot;three&quot;));

    //점수 변수
    int answer1 = 0; 
    int answer2 = 0;
    int answer3 = 0;

    //정오표 변수
    String c1 = null;
    String c2 = null;
    String c3 = null;

    //정오표
    /*각 문제의 답 변수(int correct)를 만들어 
    question1==correct1 이라고 하는 것보다 
    변수의 수를 줄일 수 있다.*/
    if (question1==4) { 
        answer1=10;
        c1=&quot;O&quot;;
    } else {
        c1=&quot;X&quot;;
    }
    if (question2==4) {
        answer2=10;
        c2=&quot;O&quot;;
    } else {
        c2=&quot;X&quot;;
    }
    if (question3==2) {
        answer3=10;
        c3=&quot;O&quot;;
    } else {
        c3=&quot;X&quot;;
    }

    //접수합계
    int sum = answer1+answer2+answer3;
%&gt;</code></pre>
<h4 id="❗-더-간단한-방법">❗ 더 간단한 방법</h4>
<pre><code class="language-java">    //작성된 답안 변수
    int question1 = Integer.parseInt(request.getParameter(&quot;one&quot;));
    int question2 = Integer.parseInt(request.getParameter(&quot;two&quot;));
    int question3 = Integer.parseInt(request.getParameter(&quot;three&quot;));

    //점수 변수
    int = score;

    //정오표 변수
    String c1 = null;
    String c2 = null;
    String c3 = null;

    //정오표
    if (question1==4) {
        score=score+1; //위의 방법보다 변수의 수가 줄어든다
        c1=&quot;O&quot;;
    } else {
        c1=&quot;X&quot;;
    }
    if (question2==4) {
        score=score+1;
        c2=&quot;O&quot;;
    } else {
        c2=&quot;X&quot;;
    }
    if (question3==2) {
        score=score+1;
        c3=&quot;O&quot;;
    } else {
        c3=&quot;X&quot;;
    }</code></pre>
<h3 id="⌨-가위바위보">⌨ 가위바위보</h3>
<pre><code class="language-java">&lt;%
    request.setCharacterEncoding(&quot;utf8&quot;); //한글 값을 받을때 필수적으로 작성한다

    // 사용자 가위바위보
    String userRsp = request.getParameter(&quot;userRsp&quot;); // &quot;가위&quot; or &quot;바위&quot; or &quot;보&quot;

    // 컴퓨터 가위바위보
    int r = (int)(Math.random()*3); // 0,1,2

    String comRsp = null;
    if(r==0) {
        comRsp = &quot;가위&quot;;
    } else if(r==1) {
        comRsp= &quot;바위&quot;;
    } else {
        comRsp= &quot;보&quot;;
    }

    // 승패
    String result = null;
    if(userRsp.equals(comRsp)) {
        result = &quot;비겼다&quot;;
    } else if((userRsp.equals(&quot;가위&quot;)&amp;&amp;comRsp.equals(&quot;보&quot;)) || (userRsp.equals(&quot;바위&quot;)&amp;&amp;comRsp.equals(&quot;보&quot;)) || (userRsp.equals(&quot;보&quot;)&amp;&amp;comRsp.equals(&quot;바위&quot;))) {
        result = &quot;이겼다&quot;;
    } else {
        result = &quot;졌다&quot;;
    }

    out.print(result);
%&gt;</code></pre>
<pre><code class="language-html">&lt;!-- 출력 페이지에 이미지를 추가하는 방법 --&gt;
&lt;img src=&quot;./img/&lt;%=userRsp%&gt;.jpg&quot;&gt;

&lt;!-- 다시시작버튼 --&gt;
&lt;form action=&quot;./userRsp.html&quot;&gt;
    &lt;input type=&quot;submit&quot; value=&quot;다시시작&quot;&gt;
&lt;/form&gt;</code></pre>
<h3 id="💪-느낀점">💪 느낀점</h3>
<ul>
<li>결과문을 먼저 분석한 후 어떻게 코드를 작성할 것인지 생각을 정리한 후에 코드작성 시작하기.</li>
<li>작성한 코드는 코드리뷰 후에 과제 제출하기.</li>
<li>주석을 이용하여 모르는 부분이나 부족한 부분은 설명을 꼭 남기기</li>
<li>깔끔한 코드작성!!!</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 구디아카데미 4일차: java 데이터타입, 연산자]]></title>
            <link>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-4%EC%9D%BC%EC%B0%A8</link>
            <guid>https://velog.io/@jin_0/TIL-%EA%B5%AC%EB%94%94%EC%95%84%EC%B9%B4%EB%8D%B0%EB%AF%B8-4%EC%9D%BC%EC%B0%A8</guid>
            <pubDate>Mon, 10 Apr 2023 14:56:23 GMT</pubDate>
            <description><![CDATA[<p>구디아카데미에서의 4일차가 끝났다.
지난 시간에 연습한 내용을 복습하고 자바의 데이터타입과 연산자를 연습하였다.</p>
<h3 id="✅이력서-만들기">✅이력서 만들기</h3>
<blockquote>
<h5 id="❗-tip">❗ TIP</h5>
</blockquote>
<ul>
<li>정렬은 블럭 요소만 가능하므로 <code>&lt;a&gt;</code>를 정렬하고 싶다면 `<div>로 감싼다.</li>
<li>id속성은 딱 하나만 나타내기 때문에 CSS에서는 <code>id</code>를 잘 사용하지 않고 <code>class</code>를 사용한다.</li>
<li><code>rowspan, colspan</code> 속성 사용시 가독성을 위해 병합되는 <code>td</code>는 지우지 말고 주석처리한다.</li>
<li>table은 컨텐츠가 비어있으면 깨지기 때문에 <code>&amp;nbsp;</code>를 넣어서 실행해보자.</li>
<li>테이블 안에 테이블을 작성하는 것은 지양하지만 CSS를 배우지 않았으므로 _테이블 안에 테이블을 작성하는 방식_으로 layout을 구성한다.</li>
</ul>
<h4 id="java_대입연산자-주석-한글데이터-받는-방법">JAVA_대입연산자, 주석, 한글데이터 받는 방법</h4>
<pre><code class="language-java">// 한줄 주석
/* 여러줄 주석*/</code></pre>
<ul>
<li>= : 왼쪽 변수에 오른쪽 값을 대입하는 연산자로, 오른쪽에 표현식이 나오면 값으로 변경 후 대입한다</li>
<li>; : 명령의 끝 (예<code>변수 = 값;</code>)</li>
<li>페이지간에 데이터를 주고 받는 방식(GET/POST)</li>
<li>액션JSP에서 한글데이터를 받는 방법<pre><code class="language-java">  request.setCharacterEncoding(&quot;utf-8&quot;);
  String name = null;
  name = request.getParameter(&quot;name&quot;);
  System.out.println(name);</code></pre>
<blockquote>
<h5 id="❗-tip-1">❗ TIP</h5>
</blockquote>
</li>
<li>null은 참조타입에만 사용할 수 있다.</li>
<li>인코딩은 절대 빼먹으면 안된다.</li>
</ul>
<h4 id="자바의-기본타입-8가지">자바의 기본타입 8가지</h4>
<p>byte(1byte), short(2byte/양수), <strong><em>int</em></strong>, long, float, <strong><em>double</em></strong>, <strong><em>boolean</em></strong>, char</p>
<pre><code class="language-java">    byte a = 1;
    // a = 1000; 불가능
    short b = 2;
    int c = 3;
    long d = 4L;
    float e = 3.1F; 
    double f = 3.1;
    boolean g = true;
    char h = &#39;구&#39;;</code></pre>
<h4 id="✅string타입">✅String타입</h4>
<p>String타입은 문자열타입
<code>String s = &quot;구디아카데미&quot;;</code></p>
<h4 id="✅값-표현식-연산자">✅값, 표현식, 연산자</h4>
<ul>
<li><p>연산자</p>
</li>
<li><p>(곱하기), /(나누기), %(나머지)
&amp;&amp;(and),||(or)</p>
<pre><code class="language-java">   int age = 0; //변수 대입연산자 값;
   int age = 777; // 변수 중복선언 에러발생
   age = 777; // age변수안에 0은 사라지고 777이 남음(덮어쓰기)
   age = 10*5; // 우측 표현식을 먼저 연산후 age = 50; 실행
   age = 10/2;
   age = 10%3;
   age = 10/3; // 정수나누기 정수는 정수만 계산

   boolean f = 3&gt;20; // f = false;
   out.println(f);

   f = (3&gt;2) &amp;&amp; (10==9); // f = true &amp;&amp; false 
   out.println(f);

   f = (3!=2) || (10&lt;=9);
   out.println(f);

   String a = &quot;구디&quot;;
   String b = &quot;아카데미&quot;;
   String c = a+b; // 문자열연결연산자
   out.println(c);
   out.println(&#39;A&#39;+&#39;B&#39;);</code></pre>
</li>
<li><p>실수연산
<code>double x = 10.0 / 3.0;</code></p>
</li>
<li><p>출력명령어
콘솔에 출력하는 명령어 <code>System.out.println();</code>
웹페이지에 출력하는 명령어 <code>out.println(x);</code></p>
</li>
<li><p>표현식</p>
<pre><code class="language-java">  age = 7;
  int limitAge = age; // 우측의 변수는 표현식이다. limitAge = 7;
  limitAge = limitAge + 10; // limitAge = 7+10; limitAge = 17;

  int y = 1;
  y = y+1;
  y += 1;
  y++;

  // 메소드 호출코드(식)도 표현식이다
  double r = Math.random(); // 0.0.... ~ 0.9.....사이값을 랜덤으로 발생
  out.println(r);</code></pre>
<h3 id="💪-느낀점">💪 느낀점</h3>
</li>
<li><p>코드 작성할 때 특수문자는 이스케이프 문자 찾아서 작성하기.</p>
</li>
<li><p><code>body</code>를 작성하기 전에 CSS를 먼저 정해야 한다. 순서가 바뀌면 안됨!!!</p>
</li>
<li><p>폼 작성시 <code>select</code>를 이용하고, 첫 <code>option</code>은 <strong>==선택==</strong> 등으로 하여 깔끔한 폼 만들기 (디테일!)</p>
</li>
</ul>
]]></description>
        </item>
    </channel>
</rss>