java字符串格式化输出问题

来源:百度知道 编辑:UC知道 时间:2024/06/24 23:29:17
package 字符串操作;

public class 字符串操作 {
public static void main(String[] args) {
System.out.printf"字母a的大写是:%c", 'A');

}
}

程序编译有错

2,System.out.printf与System.out.println有什么区别?
我写成这样System.out.printf("字母a的大写是:%c", 'A');和这样System.out.print("字母a的大写是:%c", 'A');及这样
System.out.println("字母a的大写是:%c", 'A');
都出错,错误是说参数类型不合适

System.out.printf("字母a的大写是:%c", 'A');
少了(

println通过写入行分隔符字符串终止当前行
printf使用指定格式字符串和参数将格式化字符串写入此输出流中。

首先,你写错了一个地方:System.out.print()‘print’后面没有‘f’;第二,System.out.print()输出结果不换行,而System.out.println()输出要换行。