That's actually 2 different things. There are ways to get the tower ID, but I don't know of a standard Java API for that.
On the other hand, there is a JSR spec for location and a lot of devices implement it. The normal process is that the location service uses a process called trilateralization to triangulate location to within a fairly small distance (I forget if it's 1000m or 1000ft) for my carrier, though. That's done by referencing multiple tower.
The JSR location service allows multiple inputs, so if your phone has GPS capabilities and you required GPS-level precision, it will return that data. The actual mechanisms are transparent to the application.
An IDE is no substitute for an Intelligent Developer.