Q:

Can a return statement be formatted like a printf?

I am new to java, so please be patient with me if this is a "stupid" question. Is there a way to format a return statement similar to printf("%d", a)? Here's a snippet of my code thus far.
    public static int numUnique(int a, int b, int c) {
        if (a==b && a==c) {
            System.out.println("No unique numbers.");
        } else if (a==b && a!=c) {
            System.out.printf("%d%d", a, c);
        } else if (a==c && a!=b) {
            System.out.printf("%d%d", c, b);
        } else if (b==c && b!=a) {
            System.out.printf("%d%d", b, a);
        } else {
            System.out.printf("%d%d%d", a, b, c);
        }
    }
}

I know that there needs to be a return statement in there for correct syntax, and I would like to use returns similarly to the printf being used "in theory" in my code. Thanks!
Jason

A:

If you're after a method that returns a String, you could use the String.format method, which takes the same arguments as System.out.printf.  So the code of your question would look like this.  
Note that I've introduced some spaces to stop your integers running together, and looking like a single number.
public static String numUnique(int a, int b, int c) {
    if (a==b && a==c) {
         return "No unique numbers.";
    } else if (a==b && a!=c) {
        return String.format("%d %d", a, c);
    } else if (a==c && a!=b) {
        return String.format("%d %d", c, b);
    } else if (b==c && b!=a) {
        return String.format("%d %d", b, a);
    } else {
        return String.format("%d %d %d", a, b, c);
    }
}

