Skip to main content

Simple program that checks if a number has same digits as its triple?

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2013-09-21

Hello, I'm trying to make a program that checks if a number has the same digits as its triple, so 16374, if its triple were 36471 would return true. The two numbers are put into a array and this is code to check it:
public static boolean check (int[]number, int[] third, int digits)
int matches=0;
int i=0;
int j=0;
while (i {
while (number[i]!=third[j]&&j j++;
if (j matches++;
if (matches==digits)
return true;
return false;
I've looked over it many times and tried for loops as well, but it seems that matches never ++ and always returns true if I set (matches==0).