Using ternary operator in Strings in Java

We can use ternary operator in java to find singular or plural value as below.

Here basket is a list. So if basket size is one then item is added to the String in the end else items is added based on this

 ((basket.size()==1) ? " item":" items")

Complete String

String s = "Shopping basket contains "+basket.size() + ((basket.size()==1) ? " item":" items");