programming-examples/java/Basics/How to search a word inside a string.java

11 lines
349 B
Java
Raw Normal View History

2019-11-18 14:44:36 +01:00
public class SearchStringEmp {
public static void main(String[] args) {
String strOrig = "Hello readers";
int intIndex = strOrig.indexOf("Hello");
if(intIndex == - 1) {
System.out.println("Hello not found");
} else {
System.out.println("Found Hello at index "+ intIndex);
}
}
}