Skip to content

Instantly share code, notes, and snippets.

@oleglomako
Last active September 25, 2016 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oleglomako/929631185f321d3e9ad7e870ddb3962c to your computer and use it in GitHub Desktop.
Save oleglomako/929631185f321d3e9ad7e870ddb3962c to your computer and use it in GitHub Desktop.
package com.oleglomako.SearchSubString;
import java.io.*;
public class SearchSubString {
public static String readLine() {
try {
return new BufferedReader(new InputStreamReader(System.in))
.readLine();
} catch (IOException e) {
return new String();
}
}
public static void main(String[] args) {
System.out.println("Введите строку 1:");
String firstLine = readLine();
System.out.println("Введите подстроку 2");
String secondLine = readLine();
if (firstLine.indexOf(secondLine) != -1)
System.out.println("Строка 1 содержит подстроку 2");
else
System.out.println("Строка 1 не содержит подстроку 2");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment