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

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz