gpt4 book ai didi

java - 如何在java中对齐换行符?

转载 作者:行者123 更新时间:2023-11-29 03:30:03 26 4
gpt4 key购买 nike

有什么办法可以对齐很长的文字吗?

例如这段代码:

System.out.println("\tHi this is a very long string to test the automated newline but I want to have the newline to be tab indented too.");

而不是下面

    Hi this is a very long string to test the automated newline but I want to 
have the newline to be tab indented too.

我要这个

    Hi this is a very long string to test the automated newline but I want to 
have the newline to be tab indented too.

所以,我希望换行符与第一句对齐。是否存在任何库或默认的 String Java 方法?

最佳答案

在打印语句中使用("\t"+ "Hi, this is newline")

关于java - 如何在java中对齐换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18732260/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com