I have the following lines of code:
List<Long> list = new ArrayList<>();
if (n < 0) throw new RuntimeException();
if (n == 0) return list;
I want to use Ternary condition
:
return (n < 0) ? (throw new RuntimeException()) : list;
But I have a compile time exception.
user4832640
source
to share