Displaying the output when the bit is '1' in binary equivalent of number .
for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( v . get ( i ) == 1 ) { System . out . print ( i ) ; if ( i != v . size ( ) - 1 ) System . out . print ( " , ▁ " ) ; } } System . out . println ( ) ; }