Google threats URLs --with www. and without www as two separate URLs/site. Sometimes one looses
PR juice because of this as one might unknowingly use both while link building.
As per as I know there are two ways to solve this problem.
One is to log into your Google Webmaster account and tell Google about your preference ( there is an option for it).
Another way is 301 URL redirect and it can be done by putting the following code into your .htaccess file
RewriteCond %{HTTP_HOST} !^www.yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]