When you meet someone and want to greet him, this is an example of a time when you might say "hey."
When someone rudely bumps into you, this is an example of a time when you might say "hey!" to express your upset.
Origin of hey
- Middle English hei
From American Heritage Dictionary of the English Language, 5th Edition
- From Middle English hey, hei, also without h- in ey, from Old English *hē, ēa (interjection), attested as first element in Old English hēlā, ēalā (“O!, alas!, oh!, lo!”). Cognate with Dutch he, hei (“hi, hey”), German hei (“hey, wow”), Danish and Swedish hej (“hello, hey”), Faroese hey (“hey, hello”), Icelandic hei (“hey”), see heigh. Probably a natural expression, as may be inferred from its presence with similar meaning in many other unrelated languages: for example, Burmese ဟေး (hei), Finnish hei, Unami hè, and Mandarin Chinese 哎 (āi), and various sound-alikes as Roman eho, Greek εἴα (eia), Latin eia, Sanskrit हे (he). See also hello.