void print(long l)
描述 (Description)
java.io.PrintWriter.print()方法打印一个长整数。 String.valueOf(long)生成的字符串根据平台的默认字符编码转换为字节,这些字节的写入方式与write(int)方法完全相同。
声明 (Declaration)
以下是java.io.PrintWriter.print()方法的声明。
public void print(long l)
参数 (Parameters)
l - 要打印的长度。
返回值 (Return Value)
此方法不返回值。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.io.PrintWriter.print()方法的用法。
package com.iowiki;
import java.io.*;
public class PrintWriterDemo {
public static void main(String[] args) {
long i = 4854587375487354l;
// create a new writer
PrintWriter pw = new PrintWriter(System.out);
// print long
pw.print(i);
// change the line
pw.println();
// print another long
pw.print(12315436474l);
// flush the writer
pw.flush();
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
4854587375487354
12315436474