-4

What is ? and : means in the following code?

@Override
public int getItemViewType(int position) {
    return sectionHeader.contains(position) ? TYPE_SEPARATOR : TYPE_ITEM;
}

It is from the following link:

http://javatechig.com/android/listview-with-section-header-in-android

Spidey
  • 397
  • 5
  • 19

1 Answers1

1

It is simply a shorter way of saying

if (sectionHeader.contains(position) {
  TYPE_SEPARATOR
} else {
  TYPE_ITEM
}
user372495
  • 700
  • 4
  • 11