【发布时间】:2016-10-23 01:14:50
【问题描述】:
class temp
{
public static void main(String []args)
{
String [] arp = new String [] {"Sarah is a good girl","Sarah is a bad girl"} ;// I only want to print "good" from this array and not the entire string in the below println statement.
System.out.println(arp[0]);//this will print the entire string on element[0] while i only want to print "good" from that string.
}
}
如果这个问题解决了,那么我之前的问题也将解决。
【问题讨论】:
-
查看
substring -
System.out.println("good")?似乎你需要在你的问题更具体。您是否想在“Sarah is a X girl”甚至“Y is a X {girl/boy}”中找出 X? -
@Samon Fischer 感谢您的回答,但这个字符串只是一个例子,那个地方可能有任何东西不仅仅是好的。我想要某种技术或方法,我可以打印“好”所在的第四部分。 “This is a fine House” 我只想打印第五个单词的“House”或第四个单词的“fine”。这可能是我要问的吗?
-
@Idos 谢谢,这似乎是我感兴趣的事情
标签: java arrays string printing display