Im trying to print unique value of an array using functions

this is my code
package arryofpackage;

public class UnqueElement {
public static int findUnique(int[] arr)
{
for(int i=0;i<arr.length;i++)
{
int j;
for(j=0;i<arr.length;i++)
{
if(i!=j)
{
if(arr[i]==arr[j])
{
break;
}
}
}
if(j==arr.length)
{
return arr[i];
}
}
return Integer.MAX_VALUE;
}

public static void main(String[] args)
{
int arr[]= {2,3,3,4,5};
int unique=findUnique(arr);
System.out.println(unique);
}
}
can you tell me is it good to print like this bcz im having a garbage output like this =>2147483647

@missroy


	public static int findUnique(int[] arr) {
		for (int i = 0; i < arr.length; i++) {
			int j;
			for (j = 0; j < arr.length; j++) {
				if (i != j) {
					if (arr[i] == arr[j]) {
						break;
					}
				}
			}
			if (j == arr.length) {
				return arr[i];
			}
		}
		return Integer.MAX_VALUE;
	}

	public static void main(String[] args) {
		int arr[] = { 2, 2, 3, 4, 5 };
		int unique = findUnique(arr);
		System.out.println(unique);
	}

You have just done a small mistake in nested for loop. I have corrected your code have a look at it.