Most digital cameras have autofocus capability. This means that the camera will focus on the subject for you. It is, however, important to remember that this isn't magic, it is the process of a machine. Most cameras will take a fraction of a second to establish proper focus. When the camera is properly focused, the camera generally gives the photographer an audible and visual confimation that focus was established.
When you push the camera's exposure button down halfway, it is the signal for the camera to establish proper focus. This is generally the main cause of camera hesitation: the camera must establish proper focus before it will shoot, and if you just push the button all the way down to snap a picture, it will probably take a moment before it actually takes the exposure. You should push the exposure button half-way down just before you shoot a photo, to give the camera a chance to establish focus, then when you push the button the rest of the way down, it will shoot immediately.
Auto focus must have enough light to work and you must be pointing your camera at an object which has texture or contrast for the focus to "see" the object and its focus distance. The auto focus may also fail if you're too close to your subject than the lens is designed to focus. (try Macro setting).
Another important factor in your camera's ability to auto focus, is the contrast of your subject. If you are shooting a subject that has a lot of contrast, say bright light hitting one side, or black and white stripes on a person's shirt. The camera will adjust itself to maximize the degree of contrast that it sees when it looks at that subject and this is how it senses what is in focus. This process may fail for subjects that don't have much contrast, say like a clear blue sky with a small bird in the distance. With no clouds to focus on and the birdh being so small, the camera may have difficulty becuase it cannot find any contrast. Some cameras even have a special button that looks like a mountain to help your override the camera's focusing when dealing with subject matter that is very far away and not easy to analyze.
Even subjects that are a regular distance away, but are not very contrasty may cause the camera confusion. Like a white object tacked to a white wall. The camera may have trouble because it is a white-on-white subject and it cannot see any contrast. In cases like these, what you can do is to point slightly away from your intended subject (but at another object the same distance away) and allow the camera to focus on something. Then, while holding the exposure button half-way down, re-compose the shot so that you again have your original subject. The process of holding the exposure button half-way down, will generally cause the camera to "lock" the focus so that it won't try to re-focus once you recompose.
For SLR users, manual focus can sometimes be an option. Generally there will be a switch on the lens barrel that can allow you to disengage the autofocus motor.