前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >在java中print和println_JAVA命令行参数

在java中print和println_JAVA命令行参数

作者头像
全栈程序员站长
发布2022-09-27 13:15:11
6870
发布2022-09-27 13:15:11
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

Java中的PrintWriter类的println()方法用于中断流中的行。此方法不接受任何参数或返回任何值。

用法:

public void println()

参数:此方法不接受任何参数。

返回:此方法不返回任何值。

下面的方法说明了println()方法的用法方式:

示例1:

// Java program to demonstrate

// PrintWriter println() method

import java.io.*;

class GFG {

public static void main(String[] args)

{

try {

// Create a PrintWriter instance

PrintWriter writer

= new PrintWriter(System.out);

// Print the value ‘GFG’

// to this stream using print() method

// This will put the in the

// stream till it is printed on the console

writer.print(“GFG”);

// Break the line in the stream

// using println() method

writer.println();

writer.flush();

}

catch (Exception e) {

System.out.println(e);

}

}

}

输出:

GFG

示例2:

// Java program to demonstrate

// PrintWriter println() method

import java.io.*;

class GFG {

public static void main(String[] args)

{

try {

// Create a PrintWriter instance

PrintWriter writer

= new PrintWriter(System.out);

// Print the value ‘1.65’

// to this stream using print() method

// This will put the in the

// stream till it is printed on the console

writer.print(1.65);

// Break the line in the stream

// using println() method

writer.println();

writer.flush();

}

catch (Exception e) {

System.out.println(e);

}

}

}

输出:

1.65

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/188488.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档