I find that I can open my site on matter I enter http://example.com or http://www.example.com .Do they have any difference? Is it affect the google index?
No both are considered as two different pages but there is one more problem associated with this. If two url's point to the same content then it will be considered as duplicate content. If you use wordpress then use "all-in-one seo pack" plugin which has an option called canonical url, just tick this and only one of the url will be considered.