+ 3

Is this Right?

public class Learn { public static void main(String[]args) { int value = 0; while(value < 10); { System.out.println("Hello world"); } } }

28th Oct 2020, 4:53 PM
NIHAL
NIHAL - avatar
8 Answers
+ 4
NIHAL I think there is an other error too. Just remove that semicolon from while loop. it will terminate the while loop.
28th Oct 2020, 5:18 PM
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~ - avatar
+ 4
No Syntex error but got an logical error. You should increase the value of your variable in your code (like value++). Otherwise it will be an infinite loop. cause value of that variable will be always less than 10.
28th Oct 2020, 5:11 PM
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~ - avatar
+ 4
Of course not because you have used ';' after while . If you remove it then it will be infinite loop and if you want to print 10 times then update the value by value++ or the operation you wanna do :)
30th Oct 2020, 7:37 AM
Priyanshi
Priyanshi - avatar
+ 3
Okay Ty
28th Oct 2020, 5:13 PM
NIHAL
NIHAL - avatar
+ 2
Ohh So that was the Problem
28th Oct 2020, 5:19 PM
NIHAL
NIHAL - avatar
0
Como es eseo
29th Oct 2020, 2:39 AM
Alvaro Choque Colquehuanca
Alvaro Choque Colquehuanca - avatar
0
22
29th Oct 2020, 2:15 PM
Taoufik Wad Haraz
Taoufik Wad Haraz - avatar
0
44
29th Oct 2020, 2:15 PM
Taoufik Wad Haraz
Taoufik Wad Haraz - avatar