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