-1

What does this line do? Mainly, I'm confused about the use of "?" and ":" and what they do (what are they called?).

Integer b1 = b.length > 0 ? b[0] : 0;

Apologies if the question is repeated I haven't been able to find anything related.

Shervin Rad
  • 460
  • 9
  • 21

1 Answers1

3

if b length is bigger than 0 it sets b1 to b[0] else it sets b1 to 0