What to do in case of sexual harassment?

I experienced this twice , in one of my classes I attended , the guy that was sitting next to me started to shake the table and making sounds a lot , and then the teacher shouted at him , second case , I made eye contact with a guy and then he turned around and slammed the book he was holding on the table as hard as he can and then looked at me , then the teacher asked him what was that? and then he said nothing , and the she said oh yeah right I thought it was smthg else , and then she made him sit down and study , both of these cases the teachers did smthg , but I feel like I want to stand up for myself next time , how should I act next time something similar to this happens?

What to do in case of sexual harassment?
Post Opinion