本帖最后由 _王涛 于 2013-4-3 22:53 编辑
给你举个简单例子吧:
- public class StringDemo {
- public static void main(String[] args) {
- int[] arr3={12,7,1,12,8,12,7,9,10,2};
- int count1=0;
- int count2=0;
- for(int i=0;i<arr3.length;i++)
- {
- for(int j=0;j<arr3.length;j++)
- {
- if(arr3[i]==arr3[j])
- {
- count1++;
- }
- }
- if(count1==1)
- {
- count2++;
- }
- count1=0;
- }
- System.out.println(count2);
- }
- }
复制代码 |