如何将一行string []显示为多行? [英] how to display one line string[] into multiple lines?

查看:72
本文介绍了如何将一行string []显示为多行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们具有这是java \ n这是android \ n这是.net"这样的字符串时,所有这些如何实现代码,在这里我必须以string []类型一一显示上述文本.
这是java
这是android
这是.net
因此,请帮助我解决问题

hi all how to implement code when we have the string like "this is java \n this is android \n this is .net" here i have to display the above text one by one in string[] type like.
this is java
this is android
this is .net
so help me to solve the problem

推荐答案

String.split()看起来可能会有所帮助...
String.split() looks like it might help...http://www.rgagnon.com/javadetails/java-0438.html[^]


类型string[]不能为单行字符串".这是字符串数组.您的字符串已经按照以下格式进行了格式化:将字符串分成几行显示.

也许您没有正确提出问题?根据格里夫的回答,如果您需要将一个字符串分成字符串数组,请按行尾将其拆分;否则,请执行以下步骤:如果需要在不同的行中显示字符串数组,则需要将它们与''\ n连接起来.

顺便说一句,行尾序列是平台相关的.请参见
http://en.wikipedia.org/wiki/End_of_line [ http://en.wikipedia.org/wiki/Escape_sequence [
The type string[] cannot be "one-line string". This is array of strings. Your string is already formatted in the form which would show the string separated in several lines.

Maybe you did not formulate the question correctly? If you need to work a string into array of strings, by end of lines, you need to split it, according the answer by Griff; if you need to present array of strings in different lines, you need to concatenated them with ''\n''.

By the way, end-of-line sequence is platform-dependent. See http://en.wikipedia.org/wiki/End_of_line[^].

See also: http://en.wikipedia.org/wiki/Escape_sequence[^].

—SA


这篇关于如何将一行string []显示为多行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆