Check if a negative element is found , otherwise use 0
if ( arr [ firstNegativeIndex ] < 0 ) { firstNegativeElement = arr [ firstNegativeIndex ] ; } else { firstNegativeElement = 0 ; } System . out . print ( firstNegativeElement + " ▁ " ) ; } }