본문 바로가기
JAVA

[Java] 복합 할당 연산자(Compound Assignment Operators)(예제)

by dancingcarrot 2023. 3. 8.

 

1. CompAssignTest01.java

 

public class CompAssignTest01	{
	public static void main(String[] args) {
    
    	int x=100;
    
    	x+=10;	//x=x+10
    	System.out.printf("x += %d\n", x);
    
    	x=100;
    	s-=10;	//x=x-10
    	System.out.prtinf("x -= %d\n", x);
    
    	x=100;
    	x*=10;	//x=x*10
    	System.out.printf("x *= %d\n", x);
    
    	x=100;
    	x/=10;	//x=x/10
    	System.out.printf("x /= %d\n", x);
   }
}

 

댓글