0

Java is this valid?

is j & k is valid,this (if statement) will valid? if(j < k /2)

30th May 2019, 1:36 PM
Tzion
Tzion - avatar
6 Respostas
+ 3
Yes that is a valid syntax public class Program { public static void main(String[] args) { int j = 7; int k = 10; if(j<k/2) System.out.println("yes"); else System.out.println("no"); } }
30th May 2019, 2:37 PM
[A^dr3w]
[A^dr3w] - avatar
+ 3
Yes my code example asigns value to variables j and k int j = 7; int k = 10; then it compares these two variables using the if statement and the comparison we are asking is, is j less than k/2 if(j<k/2) If the answer is yes then the code outputs yes else the code outputs no
30th May 2019, 3:19 PM
[A^dr3w]
[A^dr3w] - avatar
+ 1
I do not understand if you can link this to some code, or explain a little more as to what you want i may be able to help
30th May 2019, 3:04 PM
[A^dr3w]
[A^dr3w] - avatar
0
[A^dr3w] how it work ? 7 smaller than 10, 7 divide by 2?
30th May 2019, 2:55 PM
Tzion
Tzion - avatar
0
[A^dr3w] no i mean the code example you wrote,can u explain to me how it work when run the program
30th May 2019, 3:08 PM
Tzion
Tzion - avatar
0
[A^dr3w] Oh ! im so foolish ,i keep thinking that (j<k) true,j/2 my brain stuck,sorry
30th May 2019, 3:26 PM
Tzion
Tzion - avatar