我是java的新手,所以如果这是一个"愚蠢"的问题,请耐心等待.有没有办法格式化类似于printf("%d",a)的return语句?到目前为止,这是我的代码片段.
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我知道在那里需要一个返回语句以获得正确的语法,并且我想使用类似于在我的代码中"理论上"使用的printf的返回.谢谢!
贾森