Posts ๐Ÿต ๋ฌธ์ž์—ด๊ณผ ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐํƒ€์ž…์˜ ๊ฐ’์„ ์—ฐ๊ฒฐํ•˜๊ธฐ
Post
Cancel

๐Ÿต ๋ฌธ์ž์—ด๊ณผ ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐํƒ€์ž…์˜ ๊ฐ’์„ ์—ฐ๊ฒฐํ•˜๊ธฐ

๊ฐœ์š”

๊ธฐ๋ณธ์ ์œผ๋กœ ๋ฌธ์ž์—ด์€ ๋ฌธ์ž์—ด ์—ฐ๊ฒฐ ์—ฐ์‚ฐ์ž(concatenation)์ธ +๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ฌธ์ž์—ด์€ ๋ฌธ์ž์—ด๋ผ๋ฆฌ๋งŒ์ด ์•„๋‹ˆ๋ผ ๋‹ค๋ฅธ ์ข…๋ฅ˜์˜ ๊ฐ’๋„ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, ๊ทธ๋Ÿด ๊ฒฝ์šฐ ์—ฐ๊ฒฐ๋˜๊ธฐ ์ „ ๋‹ค๋ฅธ ์ข…๋ฅ˜์˜ ๊ฐ’์ด ๋จผ์ € ๋ฌธ์ž์—ด๋กœ ๋ฐ”๋€ ํ›„ ์—ฐ๊ฒฐ๋œ๋‹ค.

์˜ˆ์‹œ

  1. ๋ฌธ์ž์—ด + ๋ฌธ์ž์—ด
    1
    2
    
    System.out.println("Hello, " + "world!");
    //"Hello, world!"
    
  2. ๋ฌธ์ž์—ด + ๋…ผ๋ฆฌ ๊ฐ’
    1
    2
    
    System.out.println("์กธ๋ฆฐ๊ฐ€?: " + true);
    //"์กธ๋ฆฐ๊ฐ€?: true"
    
  3. ๋ฌธ์ž์—ด + ๋ฌธ์ž
    1
    2
    
    System.out.println("์„ฑ์ : " + 'A');
    //"์„ฑ์ : A"
    
  4. ๋ฌธ์ž์—ด + ๋ถ€๋™์†Œ์ˆ˜์ 
    1
    2
    
    System.out.println("ํ‚ค: " + 164.9f);
    //"ํ‚ค: 165.9"
    

    ์ด๋•Œ ๋ถ€๋™์†Œ์ˆ˜์  ์ ‘๋ฏธ์‚ฌ f(4๋น„ํŠธ ๋ฉ”๋ชจ๋ฆฌ์— ์ €์žฅํ•˜๋ผ๋Š” ์ ‘๋ฏธ์‚ฌ)๋Š” ์ƒˆ๋กœ ๋งŒ๋“ค์–ด์ง„ ๋ฌธ์ž์—ด์— ํฌํ•จ๋˜์ง€ ์•Š๋Š”๋‹ค!

This post is licensed under CC BY 4.0 by the author.

๐Ÿต ๋ถ€๋™์†Œ์ˆ˜์  ๋ฆฌํ„ฐ๋Ÿด

ํ•™์› #08์ผ์ฐจ: ์ดํด๋ฆฝ์Šค ์‚ฌ์šฉ๋ฒ•, ๊ฐ’์„ ๋ฉ”๋ชจ๋ฆฌ์— ์ €์žฅํ•˜๋Š” ๋ฐฉ์‹

Loading comments from Disqus ...