String.format("%s:%s", error.getCode(), error.getDefaultMessage())
String.format(Locale , String format, Object... args) This method generates a formatted new string using the specified locale, string format, and arguments. New strings always use the specified locale. grammar: String.format(locale,format,args...) locale: The specified locale. format: String format. args...: Arguments referenced by format specifiers in string format. If there are arguments other than format specifiers, these extra arguments are ignored. The number of parameters is variable and can be zero.
The string format parameter in the String.format() method has many options for converters:
Code analysis in the sentence:
/**
* Return the default code of this resolvable, that is,
* the last one in the codes array.
*/
public String getCode() {
return (this.codes != null && this.codes.length > 0 ? this.codes[this.codes.length - 1] : null);
}
This statement returns a nested judgment statement in the form of A?x:y, which means that if A is true, it returns x, otherwise it returns y, where A, x, and y can all be a statement.
@Override public String getDefaultMessage() { //Get the message return this.defaultMessage; }
Do not reproduce without my permission! Also refer to: http://kgd1120.iteye.com/blog/1293633