<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>developer_rooney.log</title>
        <link>https://velog.io/</link>
        <description>레벨업 하는 중</description>
        <lastBuildDate>Sun, 23 Apr 2023 16:08:57 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>developer_rooney.log</title>
            <url>https://velog.velcdn.com/images/developer_rooney/profile/450f2f10-f310-4eb5-8482-2d2fbcf1aad1/image.jpg</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. developer_rooney.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/developer_rooney" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[Java] Stream API - 2 ]]></title>
            <link>https://velog.io/@developer_rooney/Java-Stream-API-2</link>
            <guid>https://velog.io/@developer_rooney/Java-Stream-API-2</guid>
            <pubDate>Sun, 23 Apr 2023 16:08:57 GMT</pubDate>
            <description><![CDATA[<h1 id="stream-api">Stream API</h1>
<blockquote>
<h1 id="stream-중간-연산-요약">Stream 중간 연산 요약</h1>
</blockquote>
<table>
<thead>
<tr>
<th align="left">분류</th>
<th align="left">상세 분류</th>
<th align="left">설명</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Stream 필터</td>
<td align="left">filter(), distinct()</td>
<td align="left">- filter()는 구성한 스트림 내에서 특정 조건에 맞는 결과값을 필터링 하기 위해 사용됩니다.<br>- distinct()는 구성한 스트림 내에서 중복을 제거한 결과값을 반환하기 위해 사용됩니다.</td>
</tr>
<tr>
<td align="left">Stream 변환</td>
<td align="left">map(), flatMap()</td>
<td align="left">- map()은 구성한 스트림 내에서 요소들을 원하는 값으로 변환하여서 반환하기 위해 사용됩니다.<br>- flatMap()는 구성한 스트림 내에서 중복된 스트림을 평면화(flattern)하여 요소를 구성하여 반환하기 위해 사용됩니다.</td>
</tr>
<tr>
<td align="left">Stream 제한</td>
<td align="left">limit(), skip()</td>
<td align="left">- limit()는 구성한 스트림 내에서 요소의 개수를 제한하여 반환해주기 위한 목적으로 사용됩니다.<br>- skip()는 구성한 스트림 내에서 시작부터 특정 n개의 요소를 제외하여 반환해주는 목적으로 사용합니다.</td>
</tr>
<tr>
<td align="left">Stream 정렬</td>
<td align="left">sorted()</td>
<td align="left">- sorted()는 구성한 스트림 내에서 배열 혹은 리스트 그리고 Object의 요소에 대해서 오름/내림 차순을 수행하여 반환해주는 함수입니다.</td>
</tr>
<tr>
<td align="left">Stream 연산 결과 확인</td>
<td align="left">peek()</td>
<td align="left">- peek()는 구성한 스트림 내에서 각각의 요소를 조회하는 연산자료 요소 자체를 추출하는것이 아닌 스트림의 요소를 조회하는 함수입니다.</td>
</tr>
</tbody></table>
<blockquote>
<h1 id="stream-중간-연산-상세">Stream 중간 연산 상세</h1>
</blockquote>
<h2 id="stream-필터---filter">Stream 필터 - filter()</h2>
<ul>
<li>Stream 내에서 특정 조건에 맞는 결과값을 필터링 하기 위해 사용됩니다.<pre><code class="language-java">/*
* [CASE1] Array 이용한 방법
*/
// 1. Array Initialize
int[] filterIntArr = {100, 200, 300, 500};
</code></pre>
</li>
</ul>
<p>// 2. Array to IntStream : 300 이상의 값 filter
IntStream filterIntStream = Arrays.stream(filterIntArr).filter(item -&gt; item &gt;= 300);</p>
<p>// 3. IntStream to Array
filterIntArr = filterIntStream.toArray();    // 결과값 반환 : [300, 500]</p>
<p>/*</p>
<ul>
<li>[CASE2] ArrayList 이용한 방법</li>
<li>/
// 1. ArrayList Initialize
List<String> filterStrList = new ArrayList&lt;&gt;(Arrays.asList(&quot;kim&quot;, &quot;lee&quot;, &quot;park&quot;, &quot;lee&quot;, &quot;jung&quot;));</li>
</ul>
<p>// 2. ArrayList to Stream<String> : 리스트 내에 &quot;lee&quot;가 존재하는 배열을 찾습니다.
Stream<String> filterStrStream = filterStrList.stream().filter(item -&gt; item.equals(&quot;lee&quot;));</p>
<p>// 3. Stream<String> to ArrayList
filterStrList = filterStrStream.collect(Collectors.toList()); // 결과값 반환 : [&quot;lee&quot;, &quot;lee&quot;]</p>
<p>/*</p>
<ul>
<li>[CASE3] Object 이용한 방법</li>
<li>/
// 1. Object ArrayList Initialize
List<UserDto> filterUserDtoList = Arrays.asList(<pre><code>  UserDto.userBuilder().userId(&quot;adjh54&quot;).userNm(&quot;lee&quot;).userPw(&quot;1234&quot;).userSt(&quot;S&quot;).build(),
  UserDto.userBuilder().userId(&quot;ckask123&quot;).userNm(&quot;kim&quot;).userPw(&quot;4321&quot;).userSt(&quot;A&quot;).build()</code></pre>);
// 2. Object to Stream<Object> : 사용자 상태가 &quot;S&quot;인 Object 를 찾습니다.
Stream<UserDto> filterUserDtoStream = filterUserDtoList.stream().filter(item -&gt; item.getUserSt().equals(&quot;S&quot;));</li>
</ul>
<p>// 3. Stream<Object> to ArrayList
filterUserDtoList = filterUserDtoStream.collect(Collectors.toList()); // 결과값 반환: List<UserDto> 2</p>
<pre><code>&lt;br&gt;

## Stream 필터 - distinct()
- Stream 내에서 중복을 제거한 결과값을 반환하기 위해 사용됩니다.
```java
/*
 * [CASE1] Array 이용한 방법
 */
// 1. Array Initialize
int[] distinctIntArr = {1000, 5000, 5000, 7000, 12000, 12000};

// 2. Array to IntStream : Array 내에 중복되는 요소 제거
IntStream distinctIntStream = Arrays.stream(distinctIntArr).distinct();

// 3. InputStream to Array
distinctIntArr = distinctIntStream.toArray();    // 결과값 반환 : [1000, 5000, 7000, 12000]

/*
 * [CASE2] ArrayList 이용한 방법
 */
// 1. ArrayList Initialize
List&lt;String&gt; distinctStrList = new ArrayList&lt;&gt;(Arrays.asList(&quot;kim&quot;, &quot;lee&quot;, &quot;park&quot;, &quot;lee&quot;, &quot;jung&quot;));

// 2. Array to IntStream : ArrayList 내에 중복되는 요소 제거
Stream&lt;String&gt; distinctStrStream = distinctStrList.stream().distinct();

// 3. InputStream to Array
distinctStrList = distinctStrStream.collect(Collectors.toList());    // 결과값 반환 : [&quot;kim&quot;, &quot;lee&quot;, &quot;park&quot;, &quot;jung&quot;]

/*
 * [CASE3] Object 이용한 방법
 */
// 1. Object ArrayList Initialize
List&lt;UserDto&gt; distinctUserDtoList = Arrays.asList(
        UserDto.userBuilder().userId(&quot;adjh54&quot;).userNm(&quot;lee&quot;).userPw(&quot;1234&quot;).userSt(&quot;S&quot;).build(),
        UserDto.userBuilder().userId(&quot;ckask123&quot;).userNm(&quot;kim&quot;).userPw(&quot;4321&quot;).userSt(&quot;S&quot;).build()
);

// 2. Object to Stream&lt;Object&gt; : 객체간의 중복되는 요소를 확인.
Stream&lt;UserDto&gt; distinctUserDtoStream = distinctUserDtoList.stream().distinct();

// 3. Stream&lt;Object&gt; to ArrayList
distinctUserDtoList = distinctUserDtoStream.collect(Collectors.toList());   // 결과값 반환: 동일한 객체가 아니므로 구성한 모든 객체가 리스트로 반환이 됩니다.
</code></pre><br>

<h2 id="stream-변환---map">Stream 변환 - Map()</h2>
<ul>
<li>Stream 내에서 요소들을 원하는 값으로 변환하여서 반환하기 위해 사용합니다.</li>
<li>요소 내에서 조건부 검색을 위한 목적으로 사용하는 filter와 다르게 요소를 조작하여서 반환을 해줍니다.</li>
</ul>
<pre><code class="language-java">/*
 * [CASE1] Array 이용한 방법
 */
// 1. Array Initialize
int[] mapIntArr = {1000, 5000, 7000, 12000};

// 2. Array to IntStream : 배열 요소 값이 7000 이상일 경우에만 3000을 더해서 반환합니다.
IntStream mapIntStream = Arrays.stream(mapIntArr).map(item -&gt; item &gt;= 7000 ? item + 3000 : item);

// 3. InputStream to Array
mapIntArr = mapIntStream.toArray();    // 결과값 반환 : [1000, 5000, 10000, 15000]

/*
 * [CASE2] ArrayList 이용한 방법
 */
// 1. ArrayList Initialize
List&lt;String&gt; mapStrList = new ArrayList&lt;&gt;(Arrays.asList(&quot;kim&quot;, &quot;lee&quot;, &quot;park&quot;, &quot;lee&quot;, &quot;jung&quot;));

// 2. ArrayList to Stream&lt;String&gt;
Stream&lt;String&gt; strMapStream = mapStrList.stream().map(item -&gt; &quot;name ::&quot; + item);

// 3. Stream&lt;String&gt; to ArrayList
mapStrList = strMapStream.collect(Collectors.toList());      // 결과값 반환 : [&quot;name ::kim&quot;, &quot;name ::lee&quot;, &quot;name ::park&quot;, &quot;name ::lee&quot;, &quot;name ::jung&quot;]

/*
 * [CASE3] Object 이용한 방법
 */
// 1. Object ArrayList Initialize
List&lt;UserDto&gt; mapUserDtoList = Arrays.asList(
        UserDto.userBuilder().userId(&quot;adjh54&quot;).userNm(&quot;lee&quot;).userPw(&quot;1234&quot;).userSt(&quot;S&quot;).build(),
        UserDto.userBuilder().userId(&quot;ckask123&quot;).userNm(&quot;kim&quot;).userPw(&quot;4321&quot;).userSt(&quot;S&quot;).build()
);
// 2. Object to Stream&lt;Object&gt;
Stream&lt;UserDto&gt; userDtoMapStream = mapUserDtoList.stream().map(item -&gt; {
    return item.toBuilder().userNm(&quot;MyName is &quot; + item.getUserNm()).build();
});

// 3. Stream&lt;Object&gt; to ArrayList
mapUserDtoList = userDtoMapStream.collect(Collectors.toList()); // 결과값 반환: List&lt;UserDto&gt; 2

// map을 이용한 소문자를 대문자로 전환 작업
String[] toLowerCaseArr = {&quot;one&quot;, &quot;two&quot;, &quot;three&quot;};
Stream&lt;String&gt; upperCaseStream = Arrays.stream(toLowerCaseArr).map(String::toUpperCase);
</code></pre>
<br>

<h2 id="stream-변환---flatmap">Stream 변환 - flatMap()</h2>
<ul>
<li>Stream 내에서 중복된 Stream을 평면화하여 요소를 구성하여 변환하기 위해 사용됩니다. 중복된 구조의 리스트를 하나의 평면화된 리스트로 반환을 받습니다.<pre><code class="language-java">/*
* [CASE1] 2차원 int Array 이용한 방법
*/
// 1. 2차원 intArray Initialize
int[][] int2Dimension = {{1, 2}, {3, 4}, {5, 6}};
</code></pre>
</li>
</ul>
<p>// 2. 2차원 intArray to 1차원 intArray
int[] flatMapIntArr = Arrays.stream(int2Dimension).flatMapToInt(Arrays::stream).toArray();    // 결과값 반환: [1, 2, 3, 4, 5, 6]</p>
<p>/*</p>
<ul>
<li>[CASE2] 2차원 string Array 이용한 방법</li>
<li>/
// 1. 2차원 stringArray Initialize
String[][] str2Dimension = {{&quot;one&quot;, &quot;two&quot;}, {&quot;three&quot;, &quot;four&quot;}, {&quot;five&quot;, &quot;six&quot;}};</li>
</ul>
<p>// 2. 2차원 stringArray Initialize to 1차원 object Array
Object[] flatMapObjectArr = Arrays.stream(str2Dimension).flatMap(Arrays::stream).toArray(); // 결과값 반환: [&quot;one, &quot;two&quot;, &quot;three&quot;, &quot;four&quot;, &quot;five&quot;, &quot;six&quot;)</p>
<pre><code>&lt;br&gt;


## Stream 제한 - limit()
- Stream 내에서 요소의 개수를 제한하여 반환해 주기 위한 목적으로 사용됩니다.
```java
/*
 * [CASE1] Array 이용한 방법
 */
// 1. Array Initialize
int[] limitIntArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

// 2. Array to IntStream : 4개의 요소만 출력되도록 한다.
IntStream limitIntStream = Arrays.stream(limitIntArr).limit(4);

// 3. InputStream to Array
limitIntArr = limitIntStream.toArray(); // [1, 2, 3, 4]

/*
 * [CASE2] ArrayList 이용한 방법
 */
// 1. ArrayList Initialize
List&lt;String&gt; limitStrList = new ArrayList&lt;&gt;(Arrays.asList(&quot;one&quot;, &quot;two&quot;, &quot;three&quot;, &quot;four&quot;, &quot;five&quot;));

// 2. ArrayList to Stream&lt;String&gt;
Stream&lt;String&gt; limitStrStream = limitStrList.stream().limit(4);

// 2. InputStream to Array
limitStrList = limitStrStream.collect(Collectors.toList());     // [&quot;one&quot;, &quot;two&quot;, &quot;three&quot;, &quot;four&quot;]

/*
 * [CASE3] Object 이용한 방법
 */
// 1. Object ArrayList Initialize
List&lt;UserDto&gt; limitUserDtoList = Arrays.asList(
        UserDto.userBuilder().userId(&quot;adjh54&quot;).userNm(&quot;lee&quot;).userPw(&quot;1234&quot;).userSt(&quot;S&quot;).build(),
        UserDto.userBuilder().userId(&quot;ckask123&quot;).userNm(&quot;kim&quot;).userPw(&quot;4321&quot;).userSt(&quot;S&quot;).build(),
        UserDto.userBuilder().userId(&quot;fjdsl3&quot;).userNm(&quot;park&quot;).userPw(&quot;5678&quot;).userSt(&quot;S&quot;).build(),
        UserDto.userBuilder().userId(&quot;jklasd&quot;).userNm(&quot;jung&quot;).userPw(&quot;8765&quot;).userSt(&quot;S&quot;).build()
);
// 2. Object to Stream&lt;Object&gt;
Stream&lt;UserDto&gt; limitUserDtoStream = limitUserDtoList.stream().limit(2);

// 3. Stream&lt;Object&gt; to ArrayList
limitUserDtoList = limitUserDtoStream.collect(Collectors.toList()); // 결과값 반환: List&lt;UserDto&gt; 2
</code></pre><br>

<h2 id="stream-제한---skip">Stream 제한 - skip()</h2>
<ul>
<li>Stream 내에서 시작부터 특정 n개의 요소를 제외하여 반환해 주는 목적으로 사용합니다.<pre><code class="language-java">/*
* [CASE1] Array 이용한 방법
*/
// 1. Array Initialize
int[] skipIntArr = {1, 2, 3, 4, 5, 6, 7, 8};
</code></pre>
</li>
</ul>
<p>// 2. Array to IntStream : 배열 내에서 인덱스 순서대로 2개의 값을 제외한 결과값을 반환합니다.
IntStream skipIntStream = Arrays.stream(skipIntArr).skip(2);</p>
<p>// 3. InputStream to Array
skipIntArr = skipIntStream.toArray();       // [3, 4, 5, 6, 7, 8]</p>
<p>/*</p>
<ul>
<li>[CASE2] ArrayList 이용한 방법</li>
<li>/
// 1. ArrayList Initialize
List<String> skipStrList = new ArrayList&lt;&gt;(Arrays.asList(&quot;one&quot;, &quot;two&quot;, &quot;three&quot;, &quot;four&quot;, &quot;five&quot;));</li>
</ul>
<p>// 2. InputStream to Array : 리스트 내에서 인덱스 순서대로 4개의 값을 제외한 결과값을 반환합니다.
Stream<String> skipStrStream = skipStrList.stream().skip(4);</p>
<p>// 3. InputStream to Array
skipStrList = skipStrStream.collect(Collectors.toList());   // [&quot;five&quot;]</p>
<p>/*</p>
<ul>
<li>[CASE3] Object 이용한 방법</li>
<li>/
// 1. Object ArrayList Initialize
List<UserDto> skipUserDtoList = Arrays.asList(<pre><code>  UserDto.userBuilder().userId(&quot;adjh54&quot;).userNm(&quot;lee&quot;).userPw(&quot;1234&quot;).userSt(&quot;S&quot;).build(),
  UserDto.userBuilder().userId(&quot;ckask123&quot;).userNm(&quot;kim&quot;).userPw(&quot;4321&quot;).userSt(&quot;S&quot;).build(),
  UserDto.userBuilder().userId(&quot;fjdsl3&quot;).userNm(&quot;park&quot;).userPw(&quot;5678&quot;).userSt(&quot;S&quot;).build(),
  UserDto.userBuilder().userId(&quot;jklasd&quot;).userNm(&quot;jung&quot;).userPw(&quot;8765&quot;).userSt(&quot;S&quot;).build()</code></pre>);
// 2. Object to Stream<Object> : 리스트 내에서 인덱스 순서대로 2개의 값을 제외한 결과값을 반환합니다.
Stream<UserDto> skipUserDtoStream = skipUserDtoList.stream().skip(2);</li>
</ul>
<p>// 3. Stream<Object> to ArrayList
skipUserDtoList = skipUserDtoStream.collect(Collectors.toList()); // 결과값 반환: List<UserDto> 2</p>
<pre><code>&lt;br&gt;

## Stream 제한 - sorted()
- Stream 내에서 배열 혹은 리스트, Object의 요소에 대해서 오름/내림 차순을 수행하여 반환해 주는 함수입니다.
```java
/*
 * [CASE1] Array 이용한 방법
 */
// 1. Array Initialize
int[] sortNumArr1 = {10, 11, 1, 2, 4};
int[] sortNumArr2 = {0, 1, 2, 3, 4};

// 2.1. Array to IntStream : 배열을 오름차순으로 정렬합니다.
IntStream sortAscIntStreamType1 = Arrays.stream(sortNumArr1).sorted();

// 2.2. Array to Stream&lt;Integer&gt; : 배열을 내림차순으로 정렬합니다.
Stream&lt;Integer&gt; sortDescIntStreamType1 = Arrays.stream(sortNumArr1).boxed().sorted(Comparator.reverseOrder());
Stream&lt;Integer&gt; sortDescIntStreamType2 = Arrays.stream(sortNumArr2).boxed().sorted((a, b) -&gt; b - a);

// 3.1. IntStream to int[]
int[] resultSortedNumArr1 = sortAscIntStreamType1.toArray();    // 결과값 반환(오름차순) : [1, 2, 4, 10, 11]

// 3.2. Stream&lt;Integer&gt; to int[]
int[] resultSortedNumArr2 = sortDescIntStreamType1.mapToInt(i -&gt; i).toArray();      // 결과값 반환(내림차순) : [11, 10, 4, 2, 1]
int[] resultSortedNumArr3 = sortDescIntStreamType2.mapToInt(i -&gt; i).toArray();      // 결과값 반환(내림차순) : [4, 3, 2, 1, 0]

/*
 * [CASE2] ArrayList 이용한 방법
 */
// 1. ArrayList Initialize
List&lt;String&gt; sortedStrList1 = new ArrayList&lt;&gt;(Arrays.asList(&quot;aaa&quot;, &quot;bbb&quot;, &quot;ccc&quot;, &quot;ddd&quot;, &quot;AAA&quot;));
List&lt;String&gt; sortedStrList2 = new ArrayList&lt;&gt;(Arrays.asList(&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;));
List&lt;String&gt; sortedStrList3 = new ArrayList&lt;&gt;(Arrays.asList(&quot;f&quot;, &quot;b&quot;, &quot;z&quot;));

// 2.1. ArrayList to Stream&lt;String&gt; : 리스트를 오름 차순으로 정렬합니다.
Stream&lt;String&gt; sortedStrStream1 = sortedStrList1.stream().sorted(Comparator.naturalOrder());

// 2.2. ArrayList to Stream&lt;String&gt; : 리스트를 오름 차순으로 정렬합니다.
Stream&lt;String&gt; sortedStrStream2 = sortedStrList2.stream().sorted(Comparator.reverseOrder());
Stream&lt;String&gt; sortedStrStream3 = sortedStrList3.stream().sorted((a, b) -&gt; b.compareTo(a));

// 3.1. Stream&lt;String&gt; to List&lt;String&gt;
sortedStrList1 = sortedStrStream1.collect(Collectors.toList());     // 결과값 반환(오름차순) : [&quot;AAA&quot;, &quot;aaa&quot;, &quot;bbb&quot;, &quot;ccc&quot;, &quot;ddd&quot;]
sortedStrList2 = sortedStrStream2.collect(Collectors.toList());     // 결과값 반환(오름차순) : [&quot;cherry&quot;, &quot;banana&quot;, &quot;apple&quot;]
sortedStrList3 = sortedStrStream3.collect(Collectors.toList());     // 결과값 반환(오름차순) : [&quot;z&quot;, &quot;f&quot;, &quot;d&quot;]

/*
 * [CASE3] Object 이용한 방법
 */
// 1. Object ArrayList Initialize
List&lt;UserDto&gt; sortedUserDtoList = Arrays.asList(
        UserDto.userBuilder().userId(&quot;adjh54&quot;).userNm(&quot;lee&quot;).userPw(&quot;1234&quot;).userSt(&quot;S&quot;).build(),
        UserDto.userBuilder().userId(&quot;ckask123&quot;).userNm(&quot;kim&quot;).userPw(&quot;4321&quot;).userSt(&quot;S&quot;).build(),
        UserDto.userBuilder().userId(&quot;fjdsl3&quot;).userNm(&quot;park&quot;).userPw(&quot;5678&quot;).userSt(&quot;S&quot;).build()
);

// 2.1. Object to Stream&lt;Object&gt; : 리스트 내에서 userNm을 기준으로 오름차순으로 정렬합니다.
Stream&lt;UserDto&gt; sortedAscUserDtoStream = sortedUserDtoList.stream().sorted(Comparator.comparing(UserDto::getUserNm));

// 2.2. Object to Stream&lt;Object&gt; : 리스트 내에서 userNm을 기준으로 내림차순으로 정렬합니다.
Stream&lt;UserDto&gt; sortedDescUserDtoStream = sortedUserDtoList.stream().sorted(Comparator.comparing(UserDto::getUserNm).reversed());

// 3. Stream&lt;Object&gt; to ArrayList
List&lt;UserDto&gt; sortedAscUserDtoList = sortedAscUserDtoStream.collect(Collectors.toList());           // 결과값 반환: List&lt;UserDto&gt;
List&lt;UserDto&gt; sortedDescUserDtoList = sortedDescUserDtoStream.collect(Collectors.toList());         // 결과값 반환: List&lt;UserDto&gt;</code></pre><br>

<h2 id="stream-연산-결과-확인---peek">Stream 연산 결과 확인 - peek()</h2>
<ul>
<li>Stream 내에서 각각의 요소를 조회하는 연산자로 요소 자체를 추출하는 것이 아닌 
Stream의 요소를 조회하는 함수입니다.</li>
<li>해당 값은 스트림 그대로 변환하기에 다시 객체 형태로 변환이 불가능합니다.</li>
<li>peek() 함수를 사용하여 디버깅과 디버깅을 위한 중간 연산 결과값을 확인 가능합니다.</li>
</ul>
<pre><code class="language-java">/*
 * [CASE1] Array 이용한 방법
 */
// 1. Array Initialize
int[] peekIntArr = {10, 11, 1, 2, 4};

// 2. Array to IntStream
IntStream peekIntStream = Arrays.stream(peekIntArr)
        .peek(System.out::println)
        .map(i -&gt; i + 10)
        .peek(i -&gt; System.out.println(&quot;결과값 : &quot; + i))
        .map(i -&gt; i + 10);

/*
 * [CASE2] ArrayList 이용한 방법
 */
// 1. ArrayList Initialize
List&lt;String&gt; peekStrList = new ArrayList&lt;&gt;(Arrays.asList(&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;));

// 2. Array to Stream&lt;String&gt;
Stream&lt;String&gt; peekStrStream = peekStrList.stream()
        .peek(System.out::println)
        .map(i -&gt; &quot;My &quot; + i)
        .peek(i -&gt; System.out.println(&quot;결과값 : &quot; + i))
        .map(i -&gt; i + &quot; 입니다&quot;);
</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Java] Stream API - 1]]></title>
            <link>https://velog.io/@developer_rooney/Java-Stream-API-1</link>
            <guid>https://velog.io/@developer_rooney/Java-Stream-API-1</guid>
            <pubDate>Sun, 23 Apr 2023 14:24:16 GMT</pubDate>
            <description><![CDATA[<h1 id="stream-api">Stream API</h1>
<blockquote>
<h2 id="stream의-정의">Stream의 정의</h2>
</blockquote>
<ul>
<li>Stream API는 Lambda Expression을 이용한 기술 중 하나로 데이터 소스를 조작 및 가공, 변환하여 원하는 값으로 반환해주는 interface 입니다.</li>
<li>해당 기능을 사용하기 위해서는 Java 1.8 이상의 버전을 사용해야 합니다.</li>
<li>해당 Stream interface는 java.util.stream에 포함되어 있습니다.</li>
</ul>
<hr>
<blockquote>
<h2 id="stream-타입-별-객체의-종류">Stream 타입 별 객체의 종류</h2>
</blockquote>
<table>
<thead>
<tr>
<th align="center">분류</th>
<th align="center">타입</th>
<th align="center">Stream Type</th>
</tr>
</thead>
<tbody><tr>
<td align="center">정수형</td>
<td align="center">byte</td>
<td align="center">Stream&lt;Byte&gt;</td>
</tr>
<tr>
<td align="center">정수형</td>
<td align="center">short</td>
<td align="center">Stream&lt;Short&gt;</td>
</tr>
<tr>
<td align="center">정수형</td>
<td align="center">int</td>
<td align="center">IntStream</td>
</tr>
<tr>
<td align="center">정수형</td>
<td align="center">long</td>
<td align="center">LongStream</td>
</tr>
<tr>
<td align="center">문자형</td>
<td align="center">char</td>
<td align="center">Stream<Character/></td>
</tr>
<tr>
<td align="center">실수형</td>
<td align="center">float</td>
<td align="center">Stream&lt;Float&gt;</td>
</tr>
<tr>
<td align="center">실수형</td>
<td align="center">double</td>
<td align="center">DoubleStraem</td>
</tr>
<tr>
<td align="center">문자열</td>
<td align="center">String</td>
<td align="center">Stream&lt;String&gt;</td>
</tr>
<tr>
<td align="center">논리형</td>
<td align="center">boolean</td>
<td align="center">Stream&lt;Boolean&gt;</td>
</tr>
</tbody></table>
<hr>
<blockquote>
<h2 id="stream의-특징">Stream의 특징</h2>
</blockquote>
<h4 id="1-원본-데이터를-변경하지-않습니다">1. 원본 데이터를 변경하지 않습니다.</h4>
<ul>
<li>Stream API는 원본 데이터를 조회하여 별도의 Stream 객체로 생성합니다. </li>
<li>그렇기에 배열의 정렬이나 필터링 작엄을 하더라도 원본 데이터를 변경하지 않습니다.</li>
</ul>
<h4 id="2-재사용이-불가능하여-일회용으로-사용됩니다">2. 재사용이 불가능하여 일회용으로 사용됩니다.</h4>
<ul>
<li>Stream API는 이미 사용이 되어 닫혔다면 재사용이 불가능합니다.</li>
</ul>
<h4 id="3-내부-반복으로-작업을-처리합니다">3. 내부 반복으로 작업을 처리합니다.</h4>
<ul>
<li>Stream 내에서 내부적으로 반복문을 처리하기에 간결한 소스코드의 작성이 가능합니다.</li>
</ul>
<blockquote>
<h2 id="stream의-과정">Stream의 과정</h2>
</blockquote>
<ul>
<li>Stream 객체를 구성하고자 할때에 &quot;Stream 생성 -&gt; 중간 연산 -&gt; 최종 연산&quot;의 세 단계의 과정을 통해 처리가 이루어 집니다.</li>
</ul>
<pre><code class="language-java">Object.Stream().middle().final()</code></pre>
<h4 id="1-stream-생성">1. Stream 생성</h4>
<table>
<thead>
<tr>
<th align="left">분류</th>
<th align="left">상세 분류</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Stream 생성</td>
<td align="left">empty stream</td>
</tr>
<tr>
<td align="left">Stream 생성</td>
<td align="left">Collection</td>
</tr>
<tr>
<td align="left">Stream 생성</td>
<td align="left">Array</td>
</tr>
<tr>
<td align="left">Stream 생성</td>
<td align="left">Stream.builder()</td>
</tr>
<tr>
<td align="left">Stream 생성</td>
<td align="left">Stream.generate()</td>
</tr>
<tr>
<td align="left">Stream 생성</td>
<td align="left">Stream.Iterator()</td>
</tr>
<tr>
<td align="left">Stream 생성</td>
<td align="left">기본 타입 스트림</td>
</tr>
<tr>
<td align="left">Stream 생성</td>
<td align="left">파일 스트림</td>
</tr>
</tbody></table>
<h4 id="2-중간연산">2. 중간연산</h4>
<table>
<thead>
<tr>
<th align="left">분류</th>
<th align="left">상세 분류</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Stream 필터</td>
<td align="left">filter(), distinct()</td>
</tr>
<tr>
<td align="left">Stream 변환</td>
<td align="left">map(), flatMap()</td>
</tr>
<tr>
<td align="left">Stream 제한</td>
<td align="left">limit(), skip()</td>
</tr>
<tr>
<td align="left">Stream 정렬</td>
<td align="left">sorted()</td>
</tr>
<tr>
<td align="left">Stream 연산 결과 확인</td>
<td align="left">peek()</td>
</tr>
</tbody></table>
<h4 id="3-최종연산">3. 최종연산</h4>
<table>
<thead>
<tr>
<th align="left">분류</th>
<th align="left">상세 분류</th>
</tr>
</thead>
<tbody><tr>
<td align="left">요소의 출력</td>
<td align="left">forEach()</td>
</tr>
<tr>
<td align="left">요소의 검색</td>
<td align="left">findFirst(), findAny()</td>
</tr>
<tr>
<td align="left">요소의 검사</td>
<td align="left">anyMatch(), allMatch(), noneMatch()</td>
</tr>
<tr>
<td align="left">요소의 통계</td>
<td align="left">count(), min(), max()</td>
</tr>
<tr>
<td align="left">요소의 연산</td>
<td align="left">sum(), average()</td>
</tr>
<tr>
<td align="left">요소의 수집</td>
<td align="left">collect()</td>
</tr>
<tr>
<td align="left"><br></td>
<td align="left"></td>
</tr>
</tbody></table>
<blockquote>
<h2 id="stream---생성">Stream - 생성</h2>
</blockquote>
<pre><code class="language-java">// 요소 값이 존재하지 않는 빈 스트림 객체를 생성
Stream&lt;Object&gt; emptyStream = Stream.empty();

// 컬렉션 값이 존재하는 스트림 객체 생성
List&lt;String&gt; strList = new ArrayList&lt;&gt;(Arrays.asList(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;));
Stream&lt;String&gt; strStream = strList.stream();

// 배열 값이 존재하는 스트림 객체를 생성
String[] strArr = {&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;};
Stream&lt;String&gt; strStream2 = Arrays.stream(strArr);

Stream&lt;String&gt; strStream3 = Stream.of(strArr);

Stream&lt;String&gt; strStream4 = Stream.of(&quot;one&quot;, &quot;two&quot;, &quot;three&quot;);

// 빌더로 구성한 요소값들로 스트림 객체를 구성할 때
Stream&lt;String&gt; builderStream = Stream.&lt;String&gt;builder()
    .add(&quot;a&quot;)
    .add(&quot;b&quot;)
    .add(&quot;c&quot;)
    .add(&quot;d&quot;)
    .build();

// generate() 함수내에서 람다(Lambda)로 값을 지정하여 스트림을 구성할 때 사용
// 해당 스트림은 제한을 두지 않으면 무한으로 생성되기에 최대 크기를 지정해야합니다.
Stream&lt;String&gt; generatedStream = Stream.generate(() -&gt; &quot;abcd&quot;).limit(3); // [&quot;abcd&quot;,&quot;abcd&quot;,&quot;abcd&quot;,]

// iterate() 함수 내에서 람다(Lambda)로 값을 지정하여 스트림을 구성할 때 사용
Stream&lt;Integer&gt; iteratedStream = Stream.iterate(70, (n) -&gt; n + 10).limit(3) // [70, 80, 90]

// 기본타입(int, long, double)으로 값을 지정하여 스트림을 구성할 때 사용
IntStream intStream = IntStream.range(1,5);
LongStream longStream = LongStream.rangeClosed(1,5);
DoubleStream doubleStream = DoubleStream.iterate(100, (n) -&gt; n+10).limit(3);

// 파일 타입(File)을 요소값으로 지정하여 스트림을 구성할 때 사용
Stream&lt;String&gt; fileToStrStream = Files.lines(Paths.get(&quot;file.txt&quot;), Charset.forName(&quot;UTF-8&quot;));</code></pre>
<p><a href="https://adjh54.tistory.com/107">참고자료</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - 타입 변환(2)]]></title>
            <link>https://velog.io/@developer_rooney/JavaScript-%EB%9E%98%ED%8D%BC-%EA%B0%9D%EC%B2%B4</link>
            <guid>https://velog.io/@developer_rooney/JavaScript-%EB%9E%98%ED%8D%BC-%EA%B0%9D%EC%B2%B4</guid>
            <pubDate>Wed, 18 May 2022 07:29:26 GMT</pubDate>
            <description><![CDATA[<blockquote>
<h2 id="기본-데이터-타입-래퍼-객체">기본 데이터 타입 래퍼 객체</h2>
</blockquote>
<pre><code>var s = &quot;wayne rooney&quot;;
var sNum = s.length;</code></pre><p>위 코드의 첫 줄은 s가 문자열이지만, 두 번째 줄에서 length라는 프로퍼티가 사용되, s는 객체로 느껴지기도 한다.</p>
<p>이는 자바스크립트에는 <span style="color: pink">세 가지 핵심 기본 데이터 타입(숫자, 문자열, 불리언 데이터타입) 각각에 대응되는 클래스 (String, Number, Boolean) 가 정의되어 있기 때문에</span> 문맥상 일치하는 클래스로 자동 변환되어 프로퍼티를 사용할 수 있게 된다.</p>
<p>즉, 문자열을 객체 문맥으로 사용하면 내부적으로 문자열에 대한 String 객체가 자동으로 사용된다.</p>
<p><span style="color: pink">객체 문맥에서 문자열을 사용할 때 생성되는 String 객체는 일시적으로 존재하는 것이다.</span> String 객체의 프로퍼티와 메서드에 대한 접근이 완료되면 <span style="color : pink">이 객체는 더 이상 필요하지 않으므르 시스템이 객체를 회수해 간다.</pink></p>
<p>위 코드에서 문자열 s의 값은 변하지 않으며, 새로운 임시 객체인 String 객체가 생성된 후 문자열의 길이를 sNum 변수에 저장하고 임시 객체는 사라진다.</p>
<p>문자열과 마찬가지로 숫자, 불리언 데이터타입에서도 같은 동작을 한다.</p>
<blockquote>
<h2 id="객체에서-기본-타입으로-변환">객체에서 기본 타입으로 변환</h2>
</blockquote>
<p>객체는 기본 타입으로 손쉽게 변환이 된다. 먼저 NULL이 아닌 객체가 불리언 문맥에서 사용되면 true로 변환된다. </p>
<pre><code>new Boolean(false) // 내부 값은 false이지만 객체는 true 반환한다.
그 이유는 객체가 null이 아니기 때문이다.</code></pre><p>값의 변환은 그 값이 사용되는 문맥에 따라 이루어진다. (+)연산자와 비교연산자는 숫자와 문자열 둘 다에 대해 작동한다. 따라서 객체가 이 연산자들 중 하나와 함께 객체가 이 연산자들 중 하나와 함께 사용될 경우, 숫자로 변환되어야 하는지 문자열로 변환되어야 하는지가 명확하지 않다. </p>
<p><span style="color : pink">대부분의 경우 자바스크립트는 객체의 valueOf() 메서드를 호출하여 객체를 변환하고, 이 메서드가 기본 데이터 타입 값을 반환하면 그 값이 사용된다.</span></p>
<p>그러나 종종 valueOf()가 단순히 변환되지 않은 객체를 반환할 수도 있다. 이때는 자바스크립트는 toString() 메서드를 호출하여 객체를 문자열로 변환하려고 시도한다.</p>
<p>이 경우에도 예외가 있는데 Date 객체와 +연산자를 사용하면 toString() 메서드가 먼저 사용된다.</p>
<p><strong>*참고자료 : 자바스크립트 완벽 가이드 5/E</strong></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - 타입 변환 요약]]></title>
            <link>https://velog.io/@developer_rooney/JavaScript-%ED%83%80%EC%9E%85-%EB%B3%80%ED%99%98-%EC%9A%94%EC%95%BD</link>
            <guid>https://velog.io/@developer_rooney/JavaScript-%ED%83%80%EC%9E%85-%EB%B3%80%ED%99%98-%EC%9A%94%EC%95%BD</guid>
            <pubDate>Sun, 08 May 2022 18:09:38 GMT</pubDate>
            <description><![CDATA[<p><span style="color:pink">자바스크립트는 필요에 따라 그 값을 변환한다.</span> 문맥에 따라 여러가지 값들을 자동으로 변환시켜준다.</p>
<p>표를 참고하자.</p>
<table>
<thead>
<tr>
<th>값</th>
<th>문자열 문맥</th>
<th>숫자 문맥</th>
<th>불리언 문맥</th>
<th>객체 문맥</th>
</tr>
</thead>
<tbody><tr>
<td>undefined</td>
<td>&quot;undefined&quot;</td>
<td>NaN</td>
<td>false</td>
<td>Error</td>
</tr>
<tr>
<td>null</td>
<td>&quot;null&quot;</td>
<td>0</td>
<td>false</td>
<td>Error</td>
</tr>
<tr>
<td>빈 문자열이 아닌 문자열</td>
<td>그 자체</td>
<td>나타내는 숫자 or NaN</td>
<td>true</td>
<td>String 객체</td>
</tr>
<tr>
<td>빈 문자열</td>
<td>그 자체</td>
<td>0</td>
<td>false</td>
<td>String 객체</td>
</tr>
<tr>
<td>0</td>
<td>&quot;0&quot;</td>
<td>그 자체</td>
<td>false</td>
<td>Number 객체</td>
</tr>
<tr>
<td>NaN</td>
<td>&quot;NaN&quot;</td>
<td>그 자체</td>
<td>false</td>
<td>Number 객체</td>
</tr>
<tr>
<td>무한대</td>
<td>&quot;Infinity&quot;</td>
<td>그 자체</td>
<td>true</td>
<td>Number 객체</td>
</tr>
<tr>
<td>음의 무한대</td>
<td>&quot;Infinity&quot;</td>
<td>그 자체</td>
<td>true</td>
<td>Number 객체</td>
</tr>
<tr>
<td>기타 숫자</td>
<td>숫자를 문자열로 표현</td>
<td>그 자체</td>
<td>true</td>
<td>Number 객체</td>
</tr>
<tr>
<td>true</td>
<td>&quot;true&quot;</td>
<td>1</td>
<td>그 자체</td>
<td>Boolean 객체</td>
</tr>
<tr>
<td>false</td>
<td>&quot;false&quot;</td>
<td>0</td>
<td>그 자체</td>
<td>Boolean 객체</td>
</tr>
<tr>
<td>object</td>
<td>toString()</td>
<td>ValueOf(), toString(), NaN</td>
<td>true</td>
<td>그 자체</td>
</tr>
</tbody></table>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - 배열]]></title>
            <link>https://velog.io/@developer_rooney/JavaScript-%EB%B0%B0%EC%97%B4</link>
            <guid>https://velog.io/@developer_rooney/JavaScript-%EB%B0%B0%EC%97%B4</guid>
            <pubDate>Sat, 07 May 2022 16:05:43 GMT</pubDate>
            <description><![CDATA[<blockquote>
<h2 id="배열">배열</h2>
</blockquote>
<p>배열(array)은 객체처럼 <span style="color:pink">데이터 값들의 모음</span>이다. 객체 내에 포함되는 각 데이터 값에는 이름이 있는 반면, <span style="color:pink">배열의 각 데이터 값에는 번호, 즉 인텍스가 있다.</span></p>
<p>배열 이름 다음에 대괄호로 둘러싸인 인덱스를 써주어서 배열로부터 값을 가져올 수 있다. </p>
<p><span style="color:pink">배열은 다른 배열이나 객체, 함수를 포한한 어떤 자바스크립트 데이터 타입의 데이터라도 담을 수 있다.</span></p>
<pre><code>document.images[1].width</code></pre><p>이 코드는 document 객체의 images 배열에 두 번째 원소로 저장된 객체의 width 프로퍼티를 가리킨다.</p>
<p>일반적인 배열은 음수가 아닌 정수로 인덱싱된다. 반면에 연관 배열은 문자열로 인덱싱 된다. <span style="color:pink">자바스크립트는 타입의 제약이 없는 언어이므로, 자바 언어처럼 배열의 원소들이 모두 동일한 타입을 가질 필요는 없다.</span></p>
<br>

<blockquote>
<h2 id="배열-생성">배열 생성</h2>
</blockquote>
<p>배열은 Array() 생성자 함수로 생성할 수 있다. 일단 배열을 생성하고 나면, 배열의 어떤 인덱스에라도 얼마든지 <span style="color:skyblue">엘리먼트</span>를 할당할 수 있다.</p>
<pre><code>var a = new Array();
a[0] = 1.2;
a[1] = &quot;javascript&quot;;
a[2] = true;
a[3] = {x:1, y:3};</code></pre><p>배열 원소들을 Array() 생성자에 넘겨주어 배열을 초기화할 수도 있다. 때문에 앞의 배열 생성과 초기화 코드는 다음과 같이 재작성 할 수 있다.</p>
<pre><code>var a = new Array(1.2, &quot;javaScript&quot;, true, {x:1, y:3});</code></pre><p>Array() 생성자에 숫자 하나를 넘겨주면 그 숫자는 배열의 크기로 사용된다.</p>
<pre><code>var a = new Array(10); // 10의 크기를 가진 a 배열 생성</code></pre><br>

<blockquote>
<h2 id="배열-리터럴">배열 리터럴</h2>
</blockquote>
<p>배열 리터럴은 대괄호로 둘러싸인 쉼표로 구분된 값들의 목록이다. 객체 리터러러럼 중첩될 수도 있다. 또한 <span style="color:pink">객체 리터럴과 마찬가지로 배열 리터럴 내 요소로 임의의 표현식이 올 수 있으며 반드시 상수일 필요는 없다.</span></p>
<pre><code>var a = [1.2, &quot;javaScript&quot;, true, {x:1, y:3}];

var b = [[1,2,3],[4,5,6,],[7,8,9]];

var base = 1024;
var table = [base+1, base+2, base+3];

***참고자료 : 자바스크립트 완벽 가이드 5/E**</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - 객체]]></title>
            <link>https://velog.io/@developer_rooney/JavaScript-%EA%B0%9D%EC%B2%B4</link>
            <guid>https://velog.io/@developer_rooney/JavaScript-%EA%B0%9D%EC%B2%B4</guid>
            <pubDate>Sat, 07 May 2022 15:13:37 GMT</pubDate>
            <description><![CDATA[<blockquote>
<h2 id="객체">객체</h2>
</blockquote>
<p>객체는 이름 붙은 값들의 모음이다. 보통 이 이름 붙은 값들을 객체의 프로퍼티라고 부른다. 객체 프로퍼티를 참조하려면 객체 이름을 쓰고 이어서 마침표와 프로퍼티 이름을 적어주면 된다. </p>
<p>예를 들어 image라는 이름의 객체에 width와 height라고 이름 붙은 프로퍼티 두 개가 있다면 다음과 같은 방식으로 이 프로퍼티들을 참조할 수 있다.</p>
<pre><code>image.width
image.height</code></pre><p>함수가 객체 프로퍼티로 저장될 경우 그 함수를 흔히 <span style="color:pink">메서드</span>라고 부른다. 이 경우 객체 프로퍼티의 이름은 메서드 이름이 된다.</p>
<p>객체 메서드를 호출할 때는 객체로부터 함수 값을 추출하기 위해 .을 사용하고 함수를 호출하기 위해()를 사용한다. 예를 들어, document라는 객체의 wrute() 메서드를 호출하려면 다음과 같이 코드를 작성하면된다.</p>
<pre><code>document.write(&quot;ROONEY&quot;);</code></pre><p>자바스크립트에서 객체는 연관 배열의 역할도 수행한다.<span style="color:pink">  즉, 객체는 임의의 문자열에 임의의 값을 연결한다.</span> 객체가 이러한 방식으로 사용될 경우 객체 프로퍼티에 접근할 때는 다른 문법을 사용한다. 이 때는 접근하려는 프로퍼티 이름을 나타내는 문자열을 대괄호로 둘러싸면 된다.</p>
<pre><code>image[&quot;width&quot;]
image[&quot;geight&quot;]</code></pre><p>연관 배열은 많은 프로그래밍 기법에서 효과적으로 사용될 수 있는 데이터 타입이다. 조금 더 공부하고 설명해보도록 하겠다.</p>
<br>


<blockquote>
<h2 id="객체-생성">객체 생성</h2>
</blockquote>
<p>객체는 특수한 생성자 함수를 호출하여 샹성할 수 있다. 다음 몇 줄은 모두 객체를 생성하는 코드를 보여준다.</p>
<pre><code>var O = new object();
var now = new Date();
var Patter = new RegExp(&quot;\\sjava\\s&quot;,&quot;i&quot;);</code></pre><p>일단 여러분이 원하는 객체를 생성하고 나면 마음대로 객체를 사용하고 프로퍼티 값을 설정할 수 있다.</p>
<pre><code>var point = new Object();
point.x = 2.3;
point.y = -1.2;</code></pre><br>

<blockquote>
<h2 id="객체-리터럴">객체 리터럴</h2>
</blockquote>
<p>자바스크립트는 객체를 생성하고 프로퍼티를 지정하는 객체 리터럴 문법을 제공한다. 객체 리터럴은 콜론으로 구별되는 프로퍼티 이름/값 쌍들이 다시 쉼표로 분리된 목록이다. 따라서 앞에서 본 point 객체를 다음과 같이 생성하고 초기화 할 수 있다.</p>
<pre><code>var point = {x:2.3, y:-1.2};</code></pre><p>객체 리터럴 내에서 사용되는 프로퍼티 값이 상수일 필요는 없다. 프로퍼티 값으로 임의의 자바스크립트 표현식을 사용할 수 있다. 또한 객체 리터럴 내의 프로퍼티 이름으로 식별자 뿐만 아니라 문자열도 사용할 수 있다.</p>
<pre><code>var square = { &quot;upperLeft&quot;: {x:point.x, y:point.y}, 
               &#39;lowerRight&#39;: {x:point.x + side, y: point.y + side}};            </code></pre><p><strong>*참고자료 : 자바스크립트 완벽 가이드 5/E</strong></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - 함수]]></title>
            <link>https://velog.io/@developer_rooney/JavaScript-%ED%95%A8%EC%88%98</link>
            <guid>https://velog.io/@developer_rooney/JavaScript-%ED%95%A8%EC%88%98</guid>
            <pubDate>Sat, 07 May 2022 14:35:44 GMT</pubDate>
            <description><![CDATA[<blockquote>
<h2 id="함수">함수</h2>
</blockquote>
<p>함수는 자바스크립트 프로그램에 정의되어 있거나 자바스크립트 구현에 미리 정의되어 있는 실행 가능한 <span style="color:pink">코드</span> 이며, 한 번 정의하면 자바스크립트 프로그램 내에서 여러 번 실행될 수 있다.</p>
<p>함수는 계산 대상인 값들을 지정하는 전달인자나 매개변수를 넘겨받을 수 있으며, 계산 결과를 나타내는 값을 반환할 수 있다.</p>
<p>함수는 자신이 새롭게 정의할 수도 있고, 자바스크립트에서 Matr.sin() 함수 같이 정해놓은 함수를 활용할 수도 있다.</p>
<pre><code>function rooney(x) // 함수 이름은 rooney이며 전달인자 x 하나를 받는다.
{                    // 함수의 몸체 시작
    return x+3;       // 이 함수는 전달인자에 3을 더한 값을 반환한다.
}                   // 함수의 몸체 종료 </code></pre><p>함수가 정의되면 함수 이름과 괄호를 사용하여 함수를 호출 할 수 있다.</p>
<pre><code>X = Math.sin();
Y = rooeny(2);</code></pre><p>자바스크립트의 중요한 특성 중 하나는 함수도 <span style="color:pink">자바스크립트 코드로 조작할 수 있는 형태의 값</span>이라는 것이다. 
이것은 함수를 변수나, 배열, 객체에 저장할 수 있으며 다른 함수의 전달인자로 넘겨 줄 수 있다는 것을 의미한다.</p>
<p>함수도 숫자나 문자열 처럼 값이므로 다른 값처럼 객체 프로퍼티에 할당될 수 있다.
함수가 어떤 객체의 프로퍼티로 할당되면, 흔히 그 객체의 메서드라고 부른다.</p>
<br>

<blockquote>
<h2 id="함수-리터럴">함수 리터럴</h2>
</blockquote>
<p>함수 리터럴은 함수 이름을 명시하지 않는다는 것을 제외하고는 함수 정의와 모양이 동일하다.</p>
<pre><code>function park(x) { return x*2;} // park 함수 정의

var park = function(x) {return x*2;} // park 함수 리터럴
</code></pre><p>이름 없는 함수를 람다함수라고 부른다. 고급 스크립트를 작성할 때 함수 리터럴이 꽤나 편리하고 유용하게 사용될 수 있다.</p>
<p>함수를 정의하는 방법은 한 가지 더 있다. 전달인자 목록과 함수 몸체를 문자열 형태로 Function() 생성자에 전달하는 것이다.</p>
<pre><code>var park = new Function(&quot;x&quot;, &quot;return x*2;&quot;);</code></pre><p>   하지만 이런식으로 정의하면 비효율적이다.</p>
<p>   <strong>*참고자료 : 자바스크립트 완벽 가이드 5/E</strong></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - boolean]]></title>
            <link>https://velog.io/@developer_rooney/JavaScript-boolean</link>
            <guid>https://velog.io/@developer_rooney/JavaScript-boolean</guid>
            <pubDate>Thu, 05 May 2022 08:45:30 GMT</pubDate>
            <description><![CDATA[<blockquote>
<h2 id="불리언-값">불리언 값</h2>
</blockquote>
<p>불리언 데이터 타입은 두 개의 값을 가지고 있다. true or false. 불리언 값은 진리값을 나타내며 무언가가 참인지 거짓인지를 말해준다. 일반적으로 불리언 값은 자바스크립트 프로그램에서 비교의 결과로 생성된다.</p>
<pre><code>    a == 1 // 이 코드는 변수 a의 값이 1과 같은지 검사하며, 같다면 true 다르면 false가 된다.</code></pre><br>

<blockquote>
<h2 id="불리언-타입-변환">불리언 타입 변환</h2>
</blockquote>
<p>불리언 값은 다른 타입으로 변환되거나 다른 타입에서 불리언 값으로 변환될 수 있으며 대부분 자동으로 수행된다. 숫자 문맥에서는 true는 1, false는 0으로 변환되며 문자열 문맥에서는 true는 &quot;true&quot;, false는 &quot;false&quot;로 변환된다.</p>
<p>명시적 타입 변환으로는 Boolean() 함수를 사용할 수 있다.</p>
<pre><code>var boo = Boolean();</code></pre><p><strong>*참고자료 : 자바스크립트 완벽 가이드 5/E</strong></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - 문자열(2)]]></title>
            <link>https://velog.io/@developer_rooney/JavaScript-%EB%AC%B8%EC%9E%90%EC%97%B42</link>
            <guid>https://velog.io/@developer_rooney/JavaScript-%EB%AC%B8%EC%9E%90%EC%97%B42</guid>
            <pubDate>Thu, 05 May 2022 08:26:07 GMT</pubDate>
            <description><![CDATA[<pre><code>   &gt; ## 문자열 조작</code></pre><p> 숫자에 + 연산을 적용하면 숫자들이 더해지지만, 문자열에 적용하면 두 번째 문자열을 첫 번째 문자열에 이어 붙여 두 문자열을 합친다.</p>
<pre><code>three = &quot;two&quot; + &quot;plus&quot; + &quot;one&quot;; // &quot;two plus one&quot;</code></pre><br>

<blockquote>
<h2 id="숫자를-문자열로-변환">숫자를 문자열로 변환</h2>
</blockquote>
<p> 숫자는 필요할 때 문자열로 자동으로 변환된다. 문자열을 이어붙이는 표현식에서 숫자가 사용될 경우 숫자는 문자열로 변환된다. </p>
<pre><code>var n = 13;
var s = n + &quot;park&quot;; // &quot;13 park&quot;

n + &quot;&quot;; // &quot;13&quot; 숫자에 빈 문자열을 더하면 숫자열을 문자열로 바꿀 수 있다.</code></pre><p>  이 방법 이외에도 명시적으로 숫자를 문자열로 바꾸는 String() 함수, 숫자를 문자열로 변환하는 toString() 메서드를 사용하는 방법이 있다.</p>
<pre><code>var a = String(number);
var b = number.toString(기수); // 기수: 2,8,10,16 진법, 10진법은 생략가능</code></pre> <br>

<blockquote>
<h2 id="문자열을-숫자로-변환">문자열을 숫자로 변환</h2>
</blockquote>
<p>문자열이 숫자 문맥에 사용되면 자동으로 숫자로 변환된다. 곱하기나 빼기에는 문자열이 숫자로 인식되어 연산이 되지만, 더하기 연산에서는 문자열로 인식된다.</p>
<pre><code>var ABC = &quot;10&quot; * &quot;20&quot;; // 200
var bbc = &quot;1030&quot; - 0; // 1030

var ccd = &quot;1234&quot; + 0; // &quot;1234&quot; 더하기에는 문자열로 인식됨</code></pre><p>   숫자를 문자열로 변환하는 것과 마찬가지로 명시적으로 Number() 함수를 사용하거나 parseInt() 또는 parsefloat() 메서드를 사용할 수도 있다.</p>
<pre><code>var num = Number(&quot;1223&quot;); // 1223
parseInt(&quot;32&quot;) // 32
parseInt(&quot;32.1 rooney&quot;) // 32, 숫자가 아닌 문자는 무시
parseInt(&quot;12.33 rooney&quot;) // 12.33</code></pre><p>   *참고자료 : 자바스크립트 완벽 가이드 5/E</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - 문자열 (1)]]></title>
            <link>https://velog.io/@developer_rooney/JavaScript-%EB%AC%B8%EC%9E%90%EC%97%B4-1</link>
            <guid>https://velog.io/@developer_rooney/JavaScript-%EB%AC%B8%EC%9E%90%EC%97%B4-1</guid>
            <pubDate>Thu, 05 May 2022 08:15:05 GMT</pubDate>
            <description><![CDATA[<blockquote>
<h2 id="문자열">문자열</h2>
</blockquote>
<p>문자열은 Unicode 문자나 숫자, 문장부호들의 시퀀스로 텍스트를 표현하는 자바스크립트 데이터 타입이다. C, C++, Java와는 다르게 char 같은 문자 테이터 타입을 가지고 있지 않다.</p>
<p>단일 문자를 표현하려면 길이가 1인 문자열을 사용하면 된다.</p>
<pre><code>&quot;a&quot; // 단일 문자
&quot;abc&quot; // 문자열</code></pre><br>


<blockquote>
<h2 id="문자열-리스트">문자열 리스트</h2>
</blockquote>
<p>작은 따옴표(&#39;&#39;), 큰 따옴표(&quot;&quot;)로 문자열을 나타내며, 따옴표들은 서로 포함 해줄 수 있다.
문자열 리터럴은 한 줄을 넘지 말아야 하며, 문자열 리터럴 내에서 줄바꿈을 실행하고 싶다면 \n (역슬래시 + n)을 사용한다.</p>
<pre><code>&quot;&quot; // 빈 문자열
&quot;abc&quot;
&#39;abc&#39;
&quot;name = &#39;rooney&#39;&quot;
&#39;name = &quot;rooney&quot;&#39;
&quot;hello, my name is rooney \n see you later!&quot;// \n을 기준으로 열이 바뀌면서 출력됨</code></pre><p>따옴표의 순서는 상관없지만 영어의 축약형 표현들 he&#39;s 라던지 isn&#39;t 등에 들어가는 작은 따옴표를 사용할 경우, 자바스크립트에서는 문자열을 구분하는 작은따옴표로 인식하게 된다. 이 때는 이스케이프(역슬래시) 시퀀스를 사용하여 작은따옴표를 문자열로 인식하게 해준다. </p>
<pre><code>&quot;he&#39;s good man. i&#39;ll vote him.&quot; // =&gt; he&#39;s good man. i&#39;ll vote him.

&#39;he&#39;s good man. i&#39;ll vote him.&#39; // =&gt; 오류발생

&#39;he\&#39;s good man. i\&#39;ll vote him.&#39; // =&gt; he&#39;s good man. i&#39;ll vote him. 이스케이프 문자 인식</code></pre>  <br>



<blockquote>
<h2 id="이스케이프-시퀀스">이스케이프 시퀀스</h2>
</blockquote>
<pre><code>\0  //널 문자
\b  //백스페이스
\t  //수평 탭 
\n  //줄바꿈 문자
\v  //수직 탭
\f  //폼 피드
\r  //케리지 리턴
\&quot;  //큰 따옴표
\&#39;  //작은 따옴표
\\  //역 슬래시</code></pre><p>   <strong>*참고자료 : 자바스크립트 완벽 가이드 5/E</strong></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - 숫자(2)]]></title>
            <link>https://velog.io/@developer_rooney/javaScript-%EC%88%AB%EC%9E%902</link>
            <guid>https://velog.io/@developer_rooney/javaScript-%EC%88%AB%EC%9E%902</guid>
            <pubDate>Mon, 25 Apr 2022 14:44:23 GMT</pubDate>
            <description><![CDATA[<blockquote>
<h2 id="숫자-조작">숫자 조작</h2>
</blockquote>
<p>자바스크립트에서 제공하는 산술 연산자를 사용하여 숫자를 다룰 수 있다. 산술 연산자에는 우리가 흔히 하는 더하기(+), 빼기(-), 곱하기(*), 나누기(/)가 있다.</p>
<p>그 이외에도 자바스크립트가 제공하는 많은 수의 수리 함수를 하용해 한층 더 복잡한 수리 연산을 수행할 수 있다. 이 함수들은 Math라는 객체를 사용하여 접근 가능하다.</p>
<pre><code>sine_of_x = Math.sin(x); // 숫자 x의 사인 값을 계산

hypot = Math.sqrt(x*x + y*y); // 숫자 표현식의 제곱근</code></pre><br>

<blockquote>
<h2 id="특수한-값">특수한 값</h2>
</blockquote>
<p>부동소수점 값으로 표현 가능한 가장 큰 유한 수보다 더 큰 값은 Infinit로 반환된다. 음수 값보다 더 작은 무한대는 -Infinity로 반환된다. 수리 연산에서 정의되지 않은 결과값은 NaN이 반환된다.</p>
<h4 id="그-외의-특수한-값">그 외의 특수한 값</h4>
<table>
<thead>
<tr>
<th>상수</th>
<th>의미</th>
</tr>
</thead>
<tbody><tr>
<td>Infinity</td>
<td>무한대를 나타내는 값</td>
</tr>
<tr>
<td>NaN</td>
<td>숫자가 아닌 값</td>
</tr>
<tr>
<td>Number.Max_Value</td>
<td>표현 가능한 가장 큰 수</td>
</tr>
<tr>
<td>Number.MIN_Value</td>
<td>표현 가능한 가장 작은 수</td>
</tr>
<tr>
<td>Number.NaN</td>
<td>숫자가 아닌 특수한 값</td>
</tr>
<tr>
<td>Number.POSITIVE_Value</td>
<td>양의 무한대를 표현하는 특수한 값</td>
</tr>
<tr>
<td>Number.NEGATIVE_Value</td>
<td>음의 무한대를 표현하는 특수한 값</td>
</tr>
</tbody></table>
<blockquote>
<blockquote>
<p>메모장을 이용한 자바스크립트 작성</p>
</blockquote>
</blockquote>
<img src="https://velog.velcdn.com/images/developer_rooney/post/024658be-8b3a-42a8-8668-3a220056e357/image.png" width="300px">

<br>


<blockquote>
<blockquote>
<p>출력 내용</p>
</blockquote>
</blockquote>
<img src="https://velog.velcdn.com/images/developer_rooney/post/74a9a3f0-c1d2-4d4c-b46c-55ae4cbcdf9a/image.PNG" width="400px">
<img src="https://velog.velcdn.com/images/developer_rooney/post/224fa782-3d7d-4655-9575-150d6ac9ebd8/image.PNG" width="400px">
<img src="https://velog.velcdn.com/images/developer_rooney/post/9527e185-db4f-464a-a32d-7b61de837f3a/image.PNG" width="400px">
<img src="https://velog.velcdn.com/images/developer_rooney/post/1f811522-6c46-4352-86eb-974392ac3c91/image.PNG" width="400px">
<img src="https://velog.velcdn.com/images/developer_rooney/post/9034cfd0-0516-43a8-95b9-3d06d25e4083/image.PNG" width="400px">
<img src="https://velog.velcdn.com/images/developer_rooney/post/3599d94c-be88-4d5f-8caf-e638b2b99e16/image.PNG" width="400px">




<p><em>*참고 자료: 자바스크립트 완벽 가이드 5/E</em></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript - 숫자(1)]]></title>
            <link>https://velog.io/@developer_rooney/javaScript-%EC%88%AB%EC%9E%90</link>
            <guid>https://velog.io/@developer_rooney/javaScript-%EC%88%AB%EC%9E%90</guid>
            <pubDate>Mon, 25 Apr 2022 10:44:22 GMT</pubDate>
            <description><![CDATA[<blockquote>
<h2 id="가장-기본이되는-데이터-타입">가장 기본이되는 데이터 타입</h2>
</blockquote>
<p>자바스크립트는 정수 값과 실수 값을 구별하지 않는다는 점에서 C나 Java같은 프로그램 언어와 다르다. </p>
<p>모든 숫자는 실수로 표현된다. ± 1.7976931348623157 x 10^308 만큼 크고, ± 5 x 10^(-324)만큼 작은 숫자를 표현할 수 있다.</p>
<br> 

<blockquote>
<h2 id="정수-리터럴">정수 리터럴</h2>
</blockquote>
<p>자바스크립트에서 10진수 정수는 숫자 시퀀스 형태로 작성된다. </p>
<p><span style="color:skyblue"> 시퀸스란?</span>  sequence, 연속된 숫자나 문자를 의미한다.</p>
<pre><code>0
3
100000</code></pre><p>자바스크립트 숫자형식은 -9007199254740992(-2^53) ~ 9007199254740992(2^53) 사이에 있는 모든 정수를 표현할 수 있다. 이보다 더 큰 정수를 사용하면 낮은 자리 수에 대한 정밀도를 잃는다.</p>
<p>자바스크립트에서 몇몇 정수 연산자들은 -2147483648(-2^31)에서 2147483647((2^31)-1)에 이르는 32비터 정수에 대해서만 작동한다.</p>
<br>

<blockquote>
<h2 id="16진수와-8진수">16진수와 8진수</h2>
</blockquote>
<p>10진수 리터럴 이외애도 자바스크립트는 16진수 값을 인식한다. 16진수 리터럴은 &#39;0x&#39;나 &#39;0X&#39;로 시작하고 16진수 숫자들이 뒤따르는 형태다. 16진수 숫자는 0<del>9와 10부터 15까지를 표현하는 A</del>F의 문자를 사용한다.</p>
<pre><code>0xff // 15*16 + 15 = 255(10진수)

0xCAFE911 </code></pre><p><span style="color:gray"><strong><em>몇몇 자바스크립트</em></strong></span> 구현에서는 정수 리터럴을 8진수로도 표현할 수 있게 지원한다. 8진수 리터럴은 숫자 0으로 시작되고 0부터 7사이의 숫자 시퀸스가 뒤따르는 형태이다.</p>
<pre><code>0377 // 3*64 + 7*8 + 7 = 255(10진수)</code></pre><p>구현하는 자바스크립트와 그렇지 않은 자바스크립트가 있으므로 0으로 시작하는 정수리터럴 사용은 지양하자.</p>
<br>

<blockquote>
<h2 id="부동소수점-리터럴">부동소수점 리터럴</h2>
</blockquote>
<p>부동소수점 리터럴은 소수점을 가질 수 있다. 실수는 정수 부분과 소수점, 소수점 이하 부분으로 표현된다.</p>
<p>지수 표기법을 사용하여 부동소수점 리터럴을 표현할 수도 있다.</p>
<pre><code>3.14
2345.789
.33333
6.02E23 // 60.2 xx 10^23
1.4738223E-32 // 1.4738223 xx 10^-32</code></pre><p>실수는 무한 개 존재하지만 자바스크립트에서는 제한된 개수만 표현할 수 있다.</p>
<br>

<p><strong>*참고자료 : 자바스크립트 완벽 가이드 5/E</strong></p>
]]></description>
        </item>
    </channel>
</rss>