slide1
Download
Skip this Video
Download Presentation
연산자

Loading in 2 Seconds...

play fullscreen
1 / 14

연산자 - PowerPoint PPT Presentation


  • 109 Views
  • Uploaded on

연산자. unary increment prefix: ++x; int x = 5; int y = ++x; System.out.print ( x + “, “ + y);. unary increment postfix: x++; int x = 5; int y = x++; System.out.print ( x + “, “ + y);. Output. Output. File Edit Window Help. File Edit Window Help. 6, 6. 6, 5. modulus - \%.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about '연산자' - daxia


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1
연산자

unary increment prefix: ++x;

int x = 5;

int y = ++x;

System.out.print( x + “, “ + y);

unary increment postfix: x++;

int x = 5;

int y = x++;

System.out.print( x + “, “ + y);

Output

Output

File Edit WindowHelp

File Edit WindowHelp

6, 6

6, 5

modulus
modulus - %

int x = 5 % 3;

System.out.print(x);

Output

File Edit WindowHelp

2

modulus1
modulus - %

짝수? 홀수?

if(x % 2 == 0)… 짝수

else…홀수

compound operators
Compound Operators
  • x += 5;
  • x -= 5;
  • x *= 5;
  • x /= 5;
  • x %= 5;

int x = 10;

  • x = x + 5;
  • x = x – 5;
  • x = x * 5;
  • x = x / 5;
  • x = x % 5;
  • 15
  • 5
  • 50
  • 2
  • 0
implicit narrowing conversion
Implicit Narrowing Conversion

byte b = 2;

b = b + 10;

byte b = 2;

b +=10;

conversion
무슨 conversion?
  • short > int
  • byte > long
  • float > long
  • char > int
  • char > short
  • byte > char
conversion1
무슨 conversion?
  • short > int
  • byte > long
  • float > long
  • char > int
  • char > short
  • byte > char
  • widening
  • widening
  • narrowing
  • widening
  • narrowing
  • narrowing
conversions
conversions

byte

short

int

long

char

conversions between byte short and char are always narrowing conversions requiring explicit cast
conversions between byte, short and char are ALWAYS narrowing conversions requiring explicit cast

byte

short

int

long

char

conversions between byte short and char are always narrowing conversions requiring explicit cast1
conversions between byte, short and char are ALWAYS narrowing conversions requiring explicit cast

byte

short

char

Narrowing Conversion

conversions between byte short and char are always narrowing conversions requiring explicit cast2
conversions between byte, short and char are ALWAYS narrowing conversions requiring explicit cast

byte

char

short

Narrowing Conversion

slide12
conversions between byte, short and char are ALWAYS narrowing conversions requiring explicit cast

byte b = 16;

char c =

No!

b;

slide13
conversions between byte, short and char are ALWAYS narrowing conversions requiring explicit cast

byte b = 16;

char c =

b;

(char)

slide14
65535

127

byte

-128

char

0

ad