I\'m writing a code where I have an int[a] and the method should return the number of unique values. Example: {1} = 0 different values, {3,3,3} = 0 different values, {1,2} = 2 d
Try this... its pretty simple using ArrayList. You don't even need two loop. Go on
import java.util.*; public class distinctNumbers{ public static void main(String []args){ int [] numbers = {2, 7, 3, 2, 3, 7, 7}; ArrayList list=new ArrayList(); for(int i=0;i