There's a bit of misinformation in the answers above.
When you have a hub, whenever a machine wants to transfer data on the network, that data goes to -all- machines and devices connected to that hub. If you have four computer (A, B, C, D) and a router connected to your hub, and computer B wishes to send data to computer C, computer B starts transfering packets of data that are labeled as being destined for computer C. The hub, being what's called a "dumb" network device doesn't know exactly where computer C is, so instead of sending the information directly to computer C, it copies the information to all ports except the port it came in on. (that is, it sends the information to computer A, computer C, computer D and the router.)
Doing this, it can be sure that computer C does get the information, but this means that the network is needlessly saturated, as all the other computers, as well as the router, waste bandwidth receiving data that isn't meant for them. This also means, due to the nature of Ethernet LANs, that none of the computers, nor the router, can transmit data before computer B is done transfering data to computer C.
This creates another hazard known as "collision". A collision occurs when two nodes on the network attempt to send data at the same time. This is analogous to two cars driving in opposite direction on a one-lane road. They're inevitably going to crash into eachother. When this occurs, all nodes on the network discover the collision, and send "jam signals", telling all nodes on the network that there has been a collision, and that they must wait an arbitrary amount of time before transfering more data, to prevent further collisions. This means lower bandwidth and higher latency, as data is lost in collisions, making it necessary for computers to transfer that data again, and latency is induced while the computers wait for permission to transfer data again.
All computers and devices connected to a hub are part of a "collision domain", meaning that since all computers and devices connected to the hub receive all data that passes through the hub, regardless of source or destination, they're all prone to sending data that will collide with data sent from other machines in the same "collision domain."
A switch has what is known as a "switching table", which is a database containing information about the computers and devices connected to the ports in the switch. Initially, when a switch is turned on, the switching table is empty. In this state, it acts like a hub. In this case, when computer B transmits to computer C, the hub receives the data packets from router B. The switch, seeing that it has received a packet on a port that it does not have information about in the switching table, adds a line to the table stating that computer B is connected to this port. The switch now needs to transfer, or "switch" the packet to computer C. To do that, it checks its switching table for information about which port computer C is connected to. Upon not finding this information, it sends the information out all ports except for the one that it received it on, just like a hub.
Now, eventually, computer C is going to have to communicate with another device on the network, most likely computer B to tell it that it has received the data properly. When computer C sends this confirmation, the hub receives it, and adds information about computer C to the switching table. The switch now needs to switch the packet to computer B, and since it has information about computer B in its switching table, it knows which port to switch it to, and creates what is known as a "virtual circuit" between only computer B and computer C, free of any interference from other computers communicating. This is what makes the switch magical.
As opposed to the hub, the switch only sends the information to its designated destination, and avoids flooding the network. Since most networks run what is known as "full-duplex", which means that each computer has one dedicated wire for receiving data, and one dedicated wire for transmitting it, you eliminate the possibility of collisions as well, as you will never have a situation where data is transmitted in two different directions on the same wire. This means higher available bandwidth and lower latency compared to a hub.
To correct the previous answer, both hubs and switches operate as regular CSMA/CD star topologies, and not as Token Ring networks as the answer states.
I hope this is what you were looking for.