Following are two posts from Jeff Douglas and Richard Vanhook nicely illustrating with sample code on how to develop the pagination using Apex.
Salesforce.com introduced the StandardSetController in Winter ‘09 and Jeff documents the new pagination feature as pretty powerful and easy to use with standard as well as custom objects. Read More @
Pagination in VisualForce is a frequently occurring requirement for force.com developers. While the platform includes a native api for pagination in the StandardSetController class, it’s fairly inflexible; especially for complex pagination. And just as important, the native api supports pagination with sObjects only, so if you want to show pages of “plain old apex objects”, you’re out of luck. In his blog entry, Richard introduces us to pagination in apex-lang via a concept called “paginators. Read More @