1. Write a program to check whether a word exists in a string or not.
Answers
Answered by
0
Answer:
I checked
it exists
Explanation:
pls mark me brainliest
Answered by
0
Answer:
class check
{
public static void main(String []args)
{
String key = "love";// key is the word to find
String str = "I love India";
String words[]= str.split( " " );
boolean flag= false;
for(int i=0;i < words.length;i++)
if( key.equals(words[i]))
{
flag=true;
break;
}
if( flag)
System.out.println( " word found ");
else
System.out.println(" word not found");
}
}
Similar questions