public class Solution {

public int findDuplicate(int[] nums) {

int length = nums.length;

int temp=0;

boolean out = false;

for(int i=0;i<length-1;i++){

temp = nums[i];

for(int j=i+1;j<length;j++){

if(temp==nums[j]){out=true;break;}

}

if(out){break;}

}

return temp;

}

}