Java/Language Basics/Ternary operator
Версия от 18:01, 31 мая 2010; (обсуждение)
Ternary operator Demo
public class ConditionalOp
{
public static void main(String args[])
{
int value = 1;
System.out.println("I have " + value + " hat" + (value == 1 ? "." : "s."));
value++;
System.out.println("I have " + value + " hat" + (value == 1 ? "." : "s."));
}
}