A Hub is a repeater that connects more than one segment together. When a hub receives a packet of data it acts as a repeater to all of the segments connected to it. A Switch is a special sort of Repeater. Most repeaters to not look at the address of the destination of a packet of data, they simply echo the packet to all connections. A Switch looks at the source and destination addresses on packets and only echoes packets to addresses on a specific segment.
Most switches go through a learning period when they first start up.
This is when they begin building a table of what addresses are on each segment of the network. Switches are used to reduce congestion on heavily used networks. The addresses that a Switch uses are MAC addresses not IP addresses. Each network interface has a globally unique MAC address. A Bridge is a special type of repeater.