Programming Examples
Java program to find the frequency of given word present in string
Write a Java Program to find the frequency of given word that present in string.
Solution:
import java.util.*;
class WordFreq
{Â Â Â
  public static void main(String arr[])
  {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter Any String ");
    String str1=sc.nextLine();
    System.out.println("Enter Any Word for Search ");
    String sword=sc.nextLine();
    String word="";
    int count=0;
    str1=str1+" ";
    for(int a=0;a
Output
Enter Any StringÂ
today you are you that is truer than true
Enter Any Word for SearchÂ
you
Frequency of you is : 2