Post

🌒 Eclipse IDE
🌒 Eclipse IDE@EclipseJavaIDE·
What's the output here? (No trying it ;)
🌒 Eclipse IDE tweet media
English
63
48
240
0
Brilantin
Brilantin@brilantin·
@EclipseJavaIDE @java Infinite loop since the byte won’t be implicitly to int and after it reaches 127 it will start from -128 and so on
English
0
0
11
0
gorlok 🧉🧙‍♂️
@EclipseJavaIDE endless loop: byte range is -128..127. Every value is < 128 (int). Eventually, may throw OOM (heap) because S strings grows until consumes full heap size.
English
1
0
6
0
Angelos Sphyris
Angelos Sphyris@knightofmaths·
@EclipseJavaIDE I would think that it is 128. Initially, I thought it would be 128 / 8 = 16, but then I thought again...
English
0
0
2
0
Softw Dev
Softw Dev@softw_dev·
@EclipseJavaIDE I think it won't compile. When b is 127, b++ will try to assign 128 to a byte and that can only be done with an explicit typecast.
English
1
0
1
0
إليريادز
إليريادز@ilyriadz·
@EclipseJavaIDE @java 128 Because the program loop 128 times The counter b begin with 0 and the loop end when b asigned with 128 Last valid counter is 127 From 0 to 127 = 128
English
0
0
1
0
rk⚡fg 
rk⚡fg @rkfg_me·
@EclipseJavaIDE Probably zero because byte is signed and 128 == -1 so the loop won't run at all
English
3
0
1
0
Maneesh Sharma
Maneesh Sharma@Maneesh05232208·
@EclipseJavaIDE The loop will run forever and s will keep changing it’s value between-MAX_INT and MIN_INT. Sop will never be reached.
English
0
0
0
0
Manish Kumar
Manish Kumar@manish18383·
@EclipseJavaIDE Infinite loop.. it will stuck in the loop ranging from -128 to 127... It will come down to -128 after adding 1 in 127.
English
0
0
0
0
Igor Seleznëv
Igor Seleznëv@seleznyov_i·
@EclipseJavaIDE @java It will compiled successfully and start infinite loop because b will increased on every itetation and must stop repeat when b value equals or greater than 128 after next increase. But byte maximum positive value is 127, next value of b will -128 and condition will never worked.
English
0
0
0
0
Chigozirim
Chigozirim@Taibowest·
@EclipseJavaIDE @java I'm surprised at all the comments saying infinite loop. I thought bytes are usually 8 bits... Oh nvm I just remembered the sign bit is in there too. But are Java bytes also 8 bits? I read somewhere that Java string uses 16 bit representation. Time to read about bits and bytes...
English
1
0
0
0
Paylaş