Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.ArrayList;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = Integer.parseInt(sc.nextLine());
- String randWord = sc.nextLine();
- ArrayList <String> sentences = new ArrayList<>();
- for (int i = 0; i < n; i++) {
- sentences.add(sc.nextLine());
- }
- System.out.println(sentences);
- ArrayList <String> newSentences = new ArrayList<>();
- for (String sentence : sentences) {
- if (sentence.contains(randWord)) {
- newSentences.add(sentence);
- }
- }
- System.out.println(newSentences);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement