Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = 'p'
at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2691)
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2720)
at java.util.Formatter.parse(Formatter.java:2560)
at java.util.Formatter.format(Formatter.java:2501)
at java.util.Formatter.format(Formatter.java:2455)
at java.lang.String.format(String.java:2928)
at ProgramStack.java:39)
This is caused by not using the correct format in String.format() method.
Error code: System.out.println(String.format("I am a % programmer",name)) ;
Fix: System.out.println(String.format("I am a %s programmer","java")) ;
No comments:
Post a Comment