Exception in thread "main" java.lang.Error: 无法解析的编译问题:
类型 PrintStream 中的方法 printf(String, Object[])对于参数(String, String)不适用
类型 PrintStream 中的方法 printf(String, Object[])对于参数(String, int)不适用
类型 PrintStream 中的方法 printf(String, Object[])对于参数(String, String)不适用
类型 PrintStream 中的方法 printf(String, Object[])对于参数(String, int)不适用
这样子写试试Object ob[] = new Object[1];
ob[0] = "我是帅哥";
System.out.printf("你是?",ob)
System.out.printf("%s","CSDN");
第一个参数是Format string syntax,第二个参数是args。
printf中的参数:
GregorianCalendar d = new GregorianCalendar();
int weekday = d.get(Calendar.DAY_OF_WEEK);
String[] weekdayNames = new DateFormatSymbols().getShortWeekdays();
System.out.printf("%4s", weekdayNames[weekday]);
报错是说weekdayNames[weekday]不是Object[]不适用?
GregorianCalendar d = new GregorianCalendar();
int weekday = d.get(Calendar.DAY_OF_WEEK);
String[] weekdayNames = new DateFormatSymbols().getShortWeekdays();
System.out.printf("%4s", weekdayNames[weekday]);是Eclipse。
你那里应该是1.4解决方案一:上述选项处选择1.5以上
方案二:这句改成System.out.printf("%4s", new Object[]{weekdayNames[weekday]});