gpt4 book ai didi

java - 如何在Java中逐行分隔字符串?

转载 作者:行者123 更新时间:2023-12-01 16:51:30 27 4
gpt4 key购买 nike

Spring Street, 101/12
Postal Code: 8001
State: Washington

如何像上面的示例那样逐行分隔?

address.setAddress(MessageFormat.format(
"{0} {1} Postal Code: {2}, State: {3}",restSmeApplication.getAddress(),restSmeApplication.getStreet() != null ? restSmeApplication.getStreet(): "",restSmeApplication.getPostalCode(),restSmeApplication.getState() != null ? restSmeApplication.getStreet(): "")
);

最佳答案

\n 适合你 -

address.setAddress(MessageFormat.format(
"{0} \n {1} Postal Code: {2}, \n State: {3}",restSmeApplication.getAddress(),restSmeApplication.getStreet() != null ? restSmeApplication.getStreet(): "",restSmeApplication.getPostalCode(),restSmeApplication.getState() != null ? restSmeApplication.getStreet(): "")
);

关于java - 如何在Java中逐行分隔字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61677078/

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