count no of words in a line

hi
i have a string like
str=abc def ghi jkl

now i want to count the no of words in the string
please help

echo "abc def ghi jkl" | wc -w

Thanks
Penchal

Like this:
str="abc def ghi jkl"
echo $str|wc -w

satish,

I have question, are trying before posting?

hi elthox
it is working fine but i want to assign the count to a variable
i am doing

var= abc def ghi jkl mno | wc -w
echo "------------------->"$var

it is throwing an error please help

var=$(echo "abc cb fg" | wc -w)

hi aju
i am trying and then only i am asking
i am a java resource, my project people gave me the sript to remove the queues from the cluster
so i am in hurry thats why i am asking

It is not a problem for us to answer your queries... what I mean is like this u will not learn