Just wondering how collision detection is done in the most easy and fast way, i e how is it done in most games?
I'm pretty new to game programming and most games I've made use if statements comparing obects' coordinates with each other, something like this:

if (x > obstacle_x && x < obstacle_x + obstacle_width && y > obstacle_y && y < obstacle_y + obstacle_height) {
//do stuff
}

However this takes a lot of time to write and it becomes quite ineffective to check every single obstacle if there are lots of them. Is there no better and easier way?