fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main(String[] args) throws Exception {
  11. System.out.println("Printing with isMale=true");
  12. System.out.println(createSentence("Mario", true));
  13. System.out.println("Printing with isMale=false");
  14. System.out.println(createSentence("Mara", false));
  15. }
  16.  
  17. static String createSentence(String name, boolean isMale) {
  18. return String.format(isMale ? "I met %s, he was OK." : "I met %s, she was OK.", name);
  19. }
  20. }
Success #stdin #stdout 0.08s 380160KB
stdin
Standard input is empty
stdout
Printing with isMale=true
I met Mario, he was OK.
Printing with isMale=false
I met Mara, she was OK.