grodek118

Ternary operator

Nov 24th, 2021
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. package com.company;
  2.  
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. // Ternary operator
  9. int age = 18;
  10. String message = age >= 18 ?
  11. "Hooray I am an adult" : "I am not an an adult";
  12. System.out.println(message);
  13. }
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment