This question already has an answer here:
Han Solo explains to us that
Traveling through hyperspace ain't like dusting crops, boy! Without precise calculations we could fly right through a star, or bounce too close to a supernova and that'd end your trip real quick, wouldn't it.
We also know that there are established hyperspace routes.
In real life, aircraft must declare flight plans with aviation authorities. This helps prevent mid-air collisions. This doesn't seem to be the case in the Star Wars universe, as ships are always being asked for their intended destination.
Calculating a hyperspace route around planetary bodies is fairly straightforward. They move in a prescribed motion and their position can be calculated accurately.
But we see ships jumping into hyperspace with little prior planning (besides the requisite calculations), and coming out in seemingly random spots.
How do ships traveling through hyperspace avoid collisions with other ships in hyperspace (or real space), and how do they avoid collisions with other ships that may or may not be at their intended destination?