Notice
Recent Posts
Recent Comments
관리 메뉴

Developer Gonie

[1주차] 11. 복합 대입 연산자 본문

K-DigitalTraining 강의/1. Java

[1주차] 11. 복합 대입 연산자

이대곤 2022. 5. 18. 10:18

코드

public class Ex02_02_복합대입 {
	public static void main(String[] args) {
		int a=10, b=20, c=30, d=40;
		
		System.out.println("a: " + a);
		a += 3; // a=a+3
		System.out.println("a: " + a);
		
		System.out.println("b: " + b);
		b -= 5; // b=b-5
		System.out.println("b: " + b);
		
		System.out.println("c: " + c);
		c *= 2; // c=c*2
		System.out.println("c: " + c);
		
		System.out.println("d: " + d);
		d %= 6; // d=d%6
		System.out.println("d: " + d);
		
		String fruit = "apple";
		System.out.println("fruit:" + fruit);
		fruit += "banna";
		System.out.println("fruit:" + fruit);
	}
}

실행결과

a: 10
a: 13
b: 20
b: 15
c: 30
c: 60
d: 40
d: 4
fruit:apple
fruit:applebanna
Comments