Ternary Operators Def: In ternary operators we use 3 operands. syntax: expr1 ? expr2 : expr3 Note: Result of expr1 should be boolean in java. Demo: public class Ternary{ public static void main(String args[]){ //ternary operator int a=5; System.out.println( a>4 ? "a is greater than 4" : "a is less than equal to 4"); } } output is: a is greater than 4
Translate
Wednesday, 22 June 2016
Java Ternary Operator
Subscribe to:
Post Comments (Atom)
-
HII this is geometry based problem u can use simple formula to solve this here is my ac c++ soluiton is 1 2 3 4 5 6 7 8 9 1...
-
Hi,guys here is the best solution for this problem. Time Complexity:o(nlogn) Space Complexity:o(1) If u have any doubt plz comment below. #...
No comments:
Post a Comment