๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Project ESG+AI/[์‚ผ์ •KPMG]ESG ๋ฐ์ดํ„ฐ ํ™œ์šฉ ํ’€์Šคํ… ๊ฐœ๋ฐœ

6์ผ์ฐจ. ๊ณ„์‚ฐ๊ธฐ์™€ ํ•™์ ๊ณ„์‚ฐ๊ธฐ, ์ฃผ๋ฏผ ๋ฒˆํ˜ธ ์ž…๋ ฅ ํ›„ ์ถœ๋ ฅ ๊ฐ’ ์ƒ์„ฑํ•ด์ค˜

by GreenJin_S2 2025. 10. 16.

 

 

code์—์„œ

๋Œ€๋ฌธ์ž: ํƒ€์ž…

-๊ธฐ๊ณ„๊ฐ€ ์•ˆ๋งŒ๋“ค๊ณ  ๋‚ด๊ฐ€ ๋งŒ๋“ฌ! ์ด๊ฒƒ์€ ๋Œ€๋ฌธ์ž๋กœ ํ•˜๋Š” ๊ฒƒ

๋Œ€๋ฌธ์ž๋Š” ๊ฐ€๋ฌธ์˜ ์ด๋ฆ„! (์„ฑ)

 

-๋ฐธ๋ฅ˜๋Š” ์ธ๊ฐ„์ด ์–ธ์ œ๋“ ์ง€ ๋ณ€ํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋Š”, ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฅผ ๋งํ•จ

 

string->test->์ž์—ฐ

int->number->ML

float

 

character: 'a'

booleah:0, 1

 

ex)ํœ˜๋šœ๋ฃจ๋งˆ๋šœ๋ฃจ

 

-object : ๊ฐ์ฒด /ํœด๋ฉด

-subject: ๊ธฐ๊ณ„

๊ฐœ์ฒด: ์†์„ฑ๊ณผ ๊ธฐ๋Šฅ์˜ ์ง‘ํ•ฉ

** ๋Œ€๋ฌธ์ž: ํƒ€์ž…

-๊ธฐ๊ณ„๊ฐ€ ์•ˆ๋งŒ๋“ค๊ณ  ๋‚ด๊ฐ€ ๋งŒ๋“ฌ! ์ด๊ฒƒ์€ ๋Œ€๋ฌธ์ž๋กœ ํ•˜๋Š” ๊ฒƒ

๋Œ€๋ฌธ์ž๋Š” ๊ฐ€๋ฌธ์˜ ์ด๋ฆ„! (์„ฑ)

 

** ์†Œ๋ฌธ์ž: ์ด๋ฆ„!

 

 

๋””์Šคํฌ ์„ธ๊ณ„๊ด€์€ ๋ฉ”๋ชจ๋ฆฌ๋“ค์˜ ์ง‘ํ•ฉ

 

 

 

 

์ž๋ฐ”ํ™ˆํŽ˜์ด์ง€

The Java™ Tutorials

 

The Java™ Tutorials

The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See Dev.java for updated tutorials taking advantag

docs.oracle.com

 


๊ณ„์‚ฐ๊ธฐ ์™„์„ฑ!

 

 

if ์ ˆ ์‚ฌ์šฉ!

 

if (opcode.equals("+")) { result = num1 + num2; }
else if (opcode.equals("-")) { result = num1 - num2; }
else if (opcode.equals("*")) { result = num1 * num2; }
else if (opcode.equals("/")) { result = num1 / num2; }
else { 
    System.out.println("์—ฐ์‚ฐ์ž ์˜ค๋ฅ˜");
    return; // ์˜ค๋ฅ˜ ์‹œ ๋” ์ด์ƒ ์ง„ํ–‰ํ•˜์ง€ ์•Š๊ฒŒ
}

 

**์ฃผ์˜ ์‚ฌํ•ญ anObject๋Š” ์ง์ ‘ ์ ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ๊ทธ๋ƒฅ ํ™”๋ฉด์ด ๋œจ๊ฒŒ ํ•˜๋Š” ๊ฒƒ

 


ํ•™์ ๊ณ„์‚ฐ๊ธฐ

 

int score = scanner.nextInt();

 

*์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ˆซ์ž๋กœ ์ž…๋ ฅ ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ scanner.nextInt();

๊ฐ’ ์ง€์ •ํ•˜๋ฉด ๊ทธ ๊ฐ’๋งŒ ๋œจ์ง€๋งŒ ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์–ด๋–ค ์ˆซ์ž๋ฅผ ๋„ฃ์–ด๋„ ๊ฐ€๋Šฅํ•จ

* scanner.nextInt(); ์ˆซ์ž

* scanner.nextLine(); ์ค„๊ธ€

*  scanner.next : ํ•œ๊ธ€์ž

 

 

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("0๋ถ€ํ„ฐ 100๊นŒ์ง€ ์ ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์Šต๋‹ˆ๋‹ค. ");

        int score = scanner.nextInt();
        int score = scanner.ne

        if (score >= 90) {
            System.out.println("Aํ•™์ ");
        } else if (score >= 80) {
            System.out.println("Bํ•™์ ");
        } else if (score >= 70) {
            System.out.println("Cํ•™์ ");
        } else {
            System.out.println("Fํ•™์ ");
        }

    }

** ํƒ€์ž์—ฐ์Šต ํ•ฉ์‹œ๋‹ค!!!

 

 


์‹ค์Šตํ•˜๊ธฐ

์ฃผ๋ฏผ๋ฒˆํ˜ธ๋กœ ์„ฑ๋ณ„ ๋งž์ถ”๋Š” ์ž๋ฐ” ์ฝ”๋“œ ์ž‘์„ฑํ•˜๊ธฐ 

* ํ”„๋กœ๊ทธ๋žจ์„ ํ•˜๋‚˜ ๊ฐœ๋ฐœํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. 

* ๊ต์ˆ˜๊ฐ€ ์ฃผ๋ฏผ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ํ•ด๋‹น ํ•™์ƒ์ด ๋‚จ์ž์ธ์ง€, ์—ฌ์ž์ธ์ง€, ์™ธ๊ตญ์ธ์ธ์ง€ 

* ์ž๋™ ์œผ๋กœ ์ถœ๋ ฅํ•ด ์ฃผ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค์–ด ๋‹ฌ๋ž๋‹ˆ๋‹ค. 

* ์˜ค๋”๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. 

* ํ™๊ธธ๋™ : 800101 -1234567 : ๋‚จ 

* ์ž…๋ ฅ๊ฐ’์€ ์ด๋ฆ„๊ณผ ์ฃผ๋ฏผ๋ฒˆํ˜ธ์ด๊ณ  ๋‚จ์€ ์ž๋™์œผ๋กœ ์ถœ๋ ฅ๋˜๋Š” ๊ฐ’์ž…๋‹ˆ๋‹ค. 

* ํ˜„ํ–‰๋ฒ•์ƒ 1, 3์œผ๋กœ ์‹œ์ž‘๋˜๋ฉด ๋‚จ์ž, 2, 4๋กœ ์‹œ์ž‘๋˜๋ฉด ์—ฌ์ž, 5,6 ์ด๋ฉด ์™ธ๊ตญ์ธ 

* ๊ต์ˆ˜๊ฐ€ ์‹ค์ˆ˜๋กœ 0,7,8,9 ๋กœ ์‹œ์ž‘ ์ฃผ๋ฏผ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด 

* "๋‹ค์‹œ ์ž…๋ ฅํ•˜์„ธ์š”" ๋ผ๊ณ  ์•Œ๋ ค์ฃผ์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

 

 

์—ฌ๊ธฐ ๊นŒ์ง€ ํ–ˆ๋Š”๋ฐ ์ € ๋ถ€๋ถ„์ด ๋ง‰ํ˜€์„œ gpt์—๊ฒŒ ๋ฌผ์–ด๋ด„

 

1๏ธโƒฃ charAt์˜ ์˜๋ฏธ

  • charAt์€ ๋ฌธ์ž์—ด(String)์—์„œ ํŠน์ • ์œ„์น˜์˜ ๊ธ€์ž๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋ฉ”์†Œ๋“œ์˜ˆ์š”.
  • ๋ฌธ๋ฒ•:
 
String str = "Hello"; char ch = str.charAt(0); // str์˜ 0๋ฒˆ์งธ ๊ธ€์ž ๊ฐ€์ ธ์˜ค๊ธฐ → 'H'
  • 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋Š” ์ธ๋ฑ์Šค๋ฅผ ์‚ฌ์šฉํ•ด์š”.
    • ์˜ˆ: "Hello"
      • H → ์ธ๋ฑ์Šค 0
      • e → ์ธ๋ฑ์Šค 1
      • l → ์ธ๋ฑ์Šค 2
      • l → ์ธ๋ฑ์Šค 3
      • o → ์ธ๋ฑ์Šค 4

2๏ธโƒฃ ์ฃผ๋ฏผ๋ฒˆํ˜ธ ์˜ˆ์ œ

 
String jumin = "800101-1234567";
char genderCode = jumin.charAt(7); //
'-' ๋’ค ์ฒซ ์ˆซ์ž System.out.println(genderCode); // ์ถœ๋ ฅ: '1'
  • ์—ฌ๊ธฐ์„œ jumin.charAt(7)์€ ๋ฌธ์ž์—ด์˜ 7๋ฒˆ์งธ ๊ธ€์ž๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๊ฑฐ์˜ˆ์š”.
  • ๋ฐ˜ํ™˜๊ฐ’์€ char ํƒ€์ž…์ž…๋‹ˆ๋‹ค. (ํ•œ ๊ธ€์ž)

 

 

์˜ค๋ฅ˜ ๋‚ฌ๋˜๊ฑฐ!!

 

1๏ธโƒฃ ์ด๋ฆ„๊ณผ ์ฃผ๋ฏผ๋ฒˆํ˜ธ ํƒ€์ž… ๋ฌธ์ œ

 
int name = scanner.nextLine(); int jumin = scanner.nextInt();
  • nextLine()์€ **๋ฌธ์ž์—ด(String)**์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. int name์ด๋ผ๊ณ  ํ•˜๋ฉด ์˜ค๋ฅ˜! → **String name**์œผ๋กœ ๋ฐ”๊ฟ”์•ผ ํ•ด์š”.
  • ์ฃผ๋ฏผ๋ฒˆํ˜ธ๋Š” ์ˆซ์ž(int)๋กœ ๋ฐ›์œผ๋ฉด ์•ˆ ๋ผ์š”.
    • ์ด์œ : ์ฃผ๋ฏผ๋ฒˆํ˜ธ ๋’ค 7์ž๋ฆฌ ์ˆซ์ž๊ฐ€ int ๋ฒ”์œ„๋ฅผ ๋„˜์„ ์ˆ˜ ์žˆ์Œ
    • ๋˜ํ•œ charAt()์€ **๋ฌธ์ž์—ด(String)**์—์„œ๋งŒ ๊ฐ€๋Šฅ
  • ๋”ฐ๋ผ์„œ ์ฃผ๋ฏผ๋ฒˆํ˜ธ๋„ String jumin = scanner.nextLine(); ์œผ๋กœ ๋ฐ›์•„์•ผ ํ•ด์š”.

2๏ธโƒฃ charAt ์‚ฌ์šฉ

  • charAt()์€ String์—์„œ๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅ
  • int ํƒ€์ž…์—์„œ๋Š” ์ ˆ๋Œ€ ์•ˆ ๋จ.

3๏ธโƒฃ ์„ธ๋ฏธ์ฝœ๋ก (;) ๋ˆ„๋ฝ

 
int name = scanner.nextLine() // โŒ ์„ธ๋ฏธ์ฝœ๋ก  ์—†์Œ int jumin = scanner.nextInt() // โŒ ์„ธ๋ฏธ์ฝœ๋ก  ์—†์Œ
  • ๋ชจ๋“  ๋ฌธ์žฅ ๋์—๋Š” ์„ธ๋ฏธ์ฝœ๋ก  ํ•„์š”

 


์–ด์ œ ํ–ˆ๋˜ ์ปจํŠธ๋กค๋Ÿฌ ์„ค๋ช…ํ•˜๊ธฐ

 

domain

 

DTO: DATA๋ฅผ ์˜ฎ๊ธฐ๋Š” ๋ฐ•์Šค ์—ญํ• ์„ ํ•˜๋Š” ๊ฒƒ 

VO:

 

ใ„ดSET์€ ์“ฐ๋‹ค

ใ„ดGET์€ ์ฝ๋‹ค

 

 

์ด๋ฆ„ ์ง“๋Š”๊ฒƒ: setter

 

 

 

 

 

|| : or ๋œป

&& : and ๋œป

 

! ํ‹€๋ฆฐ๊ฑฐ

 

 

์ง€๊ธˆ ๋‚˜์™€์žˆ๋Š” gpt ๋Š” LLM

์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“ค ๊ฒƒ์€ SLM

 

*์ •๋ ฌ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ํ•˜๋Š” ๋ฐฉ๋ฒ• : ctrl+,

 

 

 

 


์–ด์ œ ์ด์–ด ๊ณ„์‚ฐ๊ธฐ

 

1. controller

package com.seoeunjin.api.calculator.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.seoeunjin.api.calculator.domain.CalculatorDTO;
import com.seoeunjin.api.calculator.service.CalculatorService;

@Controller
public class CalculatorController {

    private final CalculatorService calculatorService;

    public CalculatorController(CalculatorService calculatorService) {
        this.calculatorService = calculatorService;
    }
   
    @GetMapping("/calculator/calculator")
    public String calculator(@RequestParam(value = "num1", required = false) String num1,
                         @RequestParam(value = "num2", required = false) String num2) {

    System.out.println("์ปจํŠธ๋กค๋Ÿฌ๋กœ ๋“ค์–ด์˜ด");
    System.out.println("num1: " + num1 + ", num2: " + num2);

    if(num1 != null && num2 != null) {
        CalculatorDTO calculatorDTO = new CalculatorDTO();
        calculatorDTO.setNum1(num1);
        calculatorDTO.setNum2(num2);
        calculatorService.calculator(calculatorDTO);
    }

    return "calculator/calculator"; // templates/calculator/calculator.html
}

}

 

2. domain

2-1. DTO

package com.seoeunjin.api.calculator.domain;

public class CalculatorDTO {
   
    private String num1;
    private String num2;
   
    public String getNum1() {
        return num1;
    }
   
    public void setNum1(String num1) {
        this.num1 = num1;
    }
   
    public String getNum2() {
        return num2;
    }
   
    public void setNum2(String num2) {
        this.num2 = num2;
    }

}

 

2-2. VO

package com.seoeunjin.api.calculator.domain;

public class CalculatorVO {
   
    private String num1;
    private String num2;

}

 

3. service

package com.seoeunjin.api.calculator.service;

import org.springframework.stereotype.Service;

import com.seoeunjin.api.calculator.domain.CalculatorDTO;

@Service
public class CalculatorService {

    public boolean calculator(CalculatorDTO calculatorDTO) {
        System.out.println("๊ณ„์‚ฐ๊ธฐ ์„œ๋น„์Šค๋กœ ๋“ค์–ด์˜ด");
        System.out.println("์„œ๋น„์Šค๋กœ ์ „๋‹ฌ๋œ ์ˆซ์ž1 : " + calculatorDTO.getNum1());
        System.out.println("์„œ๋น„์Šค๋กœ ์ „๋‹ฌ๋œ ์ˆซ์ž2 : " + calculatorDTO.getNum2() );
        return true;
    }

}

 

4. htmlํŒŒ์ผ์€ ๋‹ค๋ฅธ ์ฐธ๊ณ  ๋ธ”๋กœ๊ทธ๋กœ ์˜ฌ๋ ค๋‘์—ˆ์Œ!

 

์ผ๋‹จ ์ด๋ ‡๊ฒŒ ๋œธ. ์ •๋‹ต์ด ๋‚˜์˜ค๋Š”๊ฑฐ๋Š” ์ด์ œ ์•Œ๋ ค์ฃผ์‹ ๋‹ค๊ณ  ํ•˜์‹ฌ

 

 

 


๋‚ด์ผ ํ• ๊ฑฐ ๋ฏธ๋ฆฌ ๋งŒ๋“ค๊ธฐ: ์ฃผ๋ฏผ๋ฒˆํ˜ธ ์ž…๋ ฅํ•˜๋Š” ๊ฒƒ

 

 


@Messenger.java
๊ฒŒํ„ฐ์™€ ์„ธํ„ฐ๋ฅผ ์ž‘์„ฑํ•ด์ค˜

 

 

 

 

 

null: ์—†์Œ์ด ์•„๋‹ˆ๋ผ ์•„์˜ˆ ์กด์žฌ ์•ˆํ•˜๋Š”๊ฒƒ