program to return true is value appears twice
import java . util .* ; class distinct { public static void main ( String [] args ) { int arr [] = { 2 , 1 , 4 }; boolean val = false ; for ( int i = 0 ; i < arr . length ; i ++){ for ( int j = i + 1 ; j < arr . length ; j ++){ if ( arr [ j ] == arr [ i ]){ val = true ; } } } System . out . println ( val ); } }