beginner at java was asked in an interview here i have to count the occurrence of each word in a given sentence. for eg( "chair is equal to chair but not equal to table." Output : chair :2, is :1, equal :2, to :2, but :1, not :1, table :1 ) I have written some part of the code and tried using for loop but i failed....
public static void main(String[] args)
{
int counter = 0;
String a = " To associate myself with an organization that provides a challenging job and an opportunity to provide innovative and diligent work.";
String[] b =a.split(" "); //stored in array and splitted
for(int i=0;i<b.length;i++)
{
counter=0;
for(int j<b.length;j>0;j--)
{
if(b[i] = b[j])
//
}
}
}
}