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