As cats groom themselves they swallow some of the loose hair from their coat. Hair cannot be digested and tends to stick together in the stomach, where it forms into a lump or hairball (also called a trichobezoar). Often, cats will vomit up the hairball. In some cases, however, it remains in the stomach for a long time and hardens into a dense mass. This can irritate the stomach or even block the digestive tract. Longhaired breeds are at greater risk.
You can limit the amount of hair your cat swallows and help prevent hairballs from forming by frequently brushing your cat to remove loose fur. If necessary, medications, such as mineral oil, can be given to help cats pass hair through the digestive tract. Some commercial cat diets and treats are also formulated to help prevent formation of hairballs. In severe cases, surgery may be required to remove the hairball.
See your veterinarians if your cat is vomiting repeatedly. Something more serious than a hairball could be to blame.