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' – Idos
'的System.out.println( 「好」)'?似乎你需要在你的問題上更具體。你是否想在「莎拉是一個X女孩」或甚至「Y是一個X女孩/男孩」中找出X? –
@Samon Fischer謝謝你的回答,但是這個字符串只是一個例子,在那個地方可能有任何東西不僅僅是好的。我想要某種技術或方法,我可以打印出「好」所在的第四部分。 「這是一個很好的房子」 我只打印第五個單詞「House」或第四個單詞「fine」。 這是可能的,我問? – user25142514