Eating in public or while walking is not a common practice in Japan. You should eat on trains only when taking a long-distance train, such as the Shinkansen. These types of trains have a tray and cup holder at every seat, and snacks are sold from a vendor trolley.