As with many other Asian countries, there are a plethora of customs associated with food and eating in Japan. One such custom involves eating while walking. Basically, don't do it. Although, there are a couple of exceptions. Apparently, it's okay to eat while in transit, such as on a bus or subway train. For whatever reason, it's also considered okay to eat ice cream while walking down the street.
It's probably because ice cream tends to melt and won't wait for you to find a place to sit down and eat before doing so. It's also considered okay to enjoy your beverage if you're beside a vending machine.