Some trains on regular rail services have windows which may be opened (to, for example, allow for ventilation). Remember that you may not throw any item from trains; this move, indeed, is against the law.
Article 77 of the Railway Safety Management Regulations prohibits anyone from throwing items from trains. The penalty for individuals is RMB 500 — 2,000; where crimes have been committed, the offender must bear criminal liabilities.
Think about it: on trains moving at speeds up to or over 100 km/h, throwing anything from trains may hit trains or trackside staff with immense force. It is even more dangerous to litter from windows if the train is in a tunnel. Any litter left on the tracks will only add to the amount of work that must be done by track staff; it is a moral problem as much as it is a legal offence.
Please dispose of litter properly — put them in the steel trays (which will be cleaned by train crew regularly) or in the designated bins. On other trains including HSR trains, use the bins, or wait until cleaning staff come around (they regularly do).