2021/08
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import java.util.Scanner; public class DiamondMaker { public static void main(String[] args) { String spacekey = " "; String starkey = "*"; int star = 1; int space = 0; int tmp = 0; while (true) { System.out.println("몇줄짜리 다이아몬드를 만드시겠습니까? 값은 홀수로 입력하셔야 합니다."); Scanner scan = new Scanner(System.in); tmp = scan.next..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 short a = 10; short b = 6; short c = 10 + 6; System.out.println(c) >> 에러가 발생한다. 왜? >> 연산처리는 int로 이뤄지기 때문. >> 따라서 short로 다시 형변환을 시켜줘야 한다. short a = 10; short b = 6; short c = (short)(10 + 6); System.out.println(c) cs 숫자 간 처리과정은 int로 처리가 된다. int보다 큰 범위(long)의 경우에는 long끼리 계산을 한다. 이건 int보다 작은 범위이기 때문. float도 계산할 때에는 double로 바뀐다.