There are several things that you can do to prevent your cat from getting hairballs in the first place. Regular grooming, even just a little bit every few days, removes the loose hairs that cause hairballs. Every loose hair you brush or comb off your cat is one less he can swallow. Get your cat used to being brushed as soon as he becomes a part of your family, and grooming will be easier for both of you. If grooming is too difficult, especially if you have a long-haired cat, consider getting him professionally groomed.
A small amount of intestinal lubrication will help hairballs make their way through the digestive system instead of coming back up. Commercial hairball remedies are usually made of a nondigestible oil or jelly such as petroleum jelly, with a feline-pleasing flavor like malt or tuna. While petroleum jelly is probably the cheapest and most effective treatment, it's also the most difficult to convince a cat to swallow. Follow the directions on the label carefully; usually, they suggest giving your cat a daily dose for a few days if he is having a lot of hairballs, then dosing him about once a week as a preventive measure. If you give your cat a hairball remedy regularly, he may never suffer from hairballs (and you may never suffer cleaning one up).
Making some adjustments to your cat's diet can also help prevent hairballs. Too many snacks, too little fiber and not enough exercise may sound like what the doctor told you at your last checkup, but it's equally sound advice for your cat. A hairball is a problem because it just sits there. Unless you get your cat's system moving a little more vigorously, hair will continue to collect, form hairballs, and be thrown up on your best rug or next to the bed for you to find with your bare feet in the middle of the night! A higher fiber diet, fewer empty-calorie snacks and a little more exercise may be all it takes to lick a hairball problem. Many cat food companies make special hairball formulas for cats that suffer from hairballs; ask your vet if one of them would be right for your cat.