这是一件好事; 通过这样的方法记录?
public static void log(final Object... messages) {
logger.info(Joiner.on(',').useForNull("null").join(messages));
}
Run Code Online (Sandbox Code Playgroud)
//在代码的其他部分,我们可以使用逗号而不是字符串连接来调用logger方法.请注意Joiner是番石榴类.
log(" Check ",obja.getXXX(),anotherObject.getMethod());
Run Code Online (Sandbox Code Playgroud)
期望是干净的代码,方便和性能.
我正在尝试编写一个程序,提示用户输入两个3×3矩阵并显示他们的产品.
例如,用户可以输入:
Matrix A: 2 4 6 8 10 12 14 16 18 Matrix B: 1 2 3 4 5.6 6.6 7.4 8.1 9
以下是我尝试过的,但我一直收到这个错误.任何帮助指出我正确的方向将不胜感激.我想把它变成一个小数位:
Exception in thread "main" java.util.IllegalFormatPrecisionException: 2
at java.util.Formatter$FormatSpecifier.checkInteger(Formatter.java:2892)
at java.util.Formatter$FormatSpecifier.(Formatter.java:2643)
at java.util.Formatter.parse(Formatter.java:2480)
at java.util.Formatter.format(Formatter.java:2414)
at java.io.PrintStream.format(PrintStream.java:920)
at java.io.PrintStream.printf(PrintStream.java:821)
at Exercise6_25.main(Exercise6_25.java:55)
import java.util.Scanner;
public class matrixCalc
{
public static void main(String args[])
{
Scanner s= new Scanner(System.in);
int i,j,k;
int n=3;
double a[][]= new double[n][n];
double b[][]= new double[n][n];
double c[][]= new double[n][n];
System.out.println("enter the array …Run Code Online (Sandbox Code Playgroud)