+ 1

Faster at runtime

I am wondering which statements are faster at run-time : normal if-else statement (if{}else {}) or ?: operator (condition?:true:false)

2nd Dec 2016, 6:17 PM
Mahmoud Heretani
Mahmoud Heretani - avatar
3 ответов
0
probably the ? operator beacause the code is shorter so you dont need that much bits ~Kamil
2nd Dec 2016, 7:22 PM
Kamil
Kamil - avatar
0
On my point of view there is no really essential difference between the two variants. It is just used to shorten the program. Normally you're writing much more code after an if - condition. But if you're simply manipulating the value of a variable, you can also use the ?:-condition. But the major advance of if-conditions is, that they can be nested.
16th Feb 2017, 9:16 AM
Philipp Brandin
Philipp Brandin - avatar
- 1
that is no proper reason. java is translated into bytecode so your argument is lacking. my guess is, they are equal.
2nd Dec 2016, 7:31 PM
Roland