Exception in thread “main” Java util. Missingformatargumentexception: format specifier ’10s’
•
Java
There is no doubt that I will miss something very obvious here, but I can't understand it Any help would be appreciated The error comes from here:
package B00166353_Grades; public class Student{ String name,banner; public Student(String name,String banner){ this.name=name; this.banner=banner; } public String toString(){ String productDetails=new String(); productDetails+=String.format("%-20s%10.2s%10s",this.name,this.banner); return productDetails; } }
Solution
The format string "% - 20s?. 2S? S" has three parameters:
>%-20s >?. 2s >?
However, only two parameters are provided:
> this. name > this. banner
The error message indicates that the third parameter (for? S) is missing
So either adjust your format string or add a third parameter
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码