Java基础 println print 实现输出换行

  •     JDK :OpenJDK-11
  •      OS :CentOS 7.6.1810
  •      IDE :Eclipse 2019‑03
  • typesetting :Markdown

code

package per.jizuiku.base;

/**
 * @author 给最苦
 * @date 2019/06/29
 * @blog www.cnblogs.com/jizuiku
 */
class Demo {

    /**
     * @param args
     */
    public static void main(String[] args) {

        // 输出后 换行
        System.out.print("hello world");
        System.out.println();
        System.out.print("hello world" + "\n");
        System.out.print("hello world");
        System.out.print(" end");
    }
}

result

hello world
hello world
hello world end

sourceCode

/**
    * Terminates the current line by writing the line separator string.  The
    * line separator string is defined by the system property
    * {@code line.separator}, and is not necessarily a single newline
    * character ({@code '\n'}).
    */
public void println() {
    newLine();
}
/**
    * Prints a string.  If the argument is {@code null} then the string
    * {@code "null"} is printed.  Otherwise, the string's characters are
    * converted into bytes according to the platform's default character
    * encoding, and these bytes are written in exactly the manner of the
    * {@link #write(int)} method.
    *
    * @param      s   The {@code String} to be printed
    */
public void print(String s) {
    write(String.valueOf(s));
}

resource

  • [ JDK ] openjdk.java.net
  • [ doc - 参考 ] docs.oracle.com/en/java/javase/11
  • [ 规范 - 推荐 ] yq.aliyun.com/articles/69327
  • [ 规范 - 推荐 ] google.github.io/styleguide
  • [ 源码 ] hg.openjdk.java.net
  • [ OS ] www.centos.org
  • [ IDE ] www.eclipse.org/downloads/packages
  • [ 平台 ] www.cnblogs.com


感谢帮助过 给最苦 的人们。
Java、Groovy和Scala等基于JVM的语言,优秀,值得学习。
规范的命名和代码格式等,有助于沟通和理解。
JVM的配置、监控与优化,比较实用,值得学习。

posted @   给最苦  阅读(10313)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示