[Java] ์ž๋ฐ” ์Šค์บ๋„ˆ(Scanner) ํด๋ž˜์Šค์™€ hasNext() / next() ํ•จ์ˆ˜ โœ๏ธ
ยท
Java
๐Ÿ‘จ‍๐Ÿ’ป ์ž๋ฐ”๋ฅผ ๊ณต๋ถ€ํ•˜๋Š” ์ค‘, ์ฒ˜์Œ์œผ๋กœ ์ ‘ํ•œ ์ž…๋ ฅ๋ฐฉ์‹ Scanner ํด๋ž˜์Šค์ด๋‹ค. ์ฑ…์— ๋‚ด์šฉ์— ๋”ฐ๋ผ ์•„๋ž˜์™€ ๊ฐ™์ด ์‹ค์Šต์„ ํ•˜๋˜์ค‘ ์ •์ˆ˜๊ฐ€ ์•„๋‹Œ ๊ฐ’์„ ์ž…๋ ฅํ–ˆ์„๋•Œ ์ •์ˆ˜๊ฐ€ ์•„๋‹Œ ๊ฒฝ์šฐ ํŒ๋ณ„ํ•˜๋Š” ๊ฐ„๋‹จํ•œํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค๊ณ  ์‹ถ์—ˆ๋‹ค. Scanner ํด๋ž˜์Šค๋ฅผ ์‚ฌ์šฉํ•  ์‹œ util ํŒจํ‚ค์ง€๋ฅผ import ๋ฅผ ํ†ตํ•ด ํ˜ธ์ถœํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค. ์ •์ˆ˜ ์ž…๋ ฅ๊ฐ’์— ๋Œ€ํ•ด์„œ๋งŒ ์ž…๋ ฅ๋‚ด์šฉ ์ถœ๋ ฅํ•˜๊ธฐimport java.util.Scanner;public class scanner { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.>"); String input = sc.nextLine(); int num ..