I am reading some algebraic topological book, where they said that the p-th homology group tells us how many p-dimensional holes inside the set. How should I understand this? I know that in the planar case, the 1-th order homology group tells us exactly how many 1-holes the set has, but I do not have a good feeling about the p-holes, could anybody explain this by some very simple examples? 


Also they said the cohomology groups are dual to homology group, is there also a good geometric meaning of cohomology group? I heard some duality result, like the Alexander duality between homology group and cohomology group, but I do not know the real meanings. 



What is the geometric meaning of homology group and cohomology group?
I don't think counting even 1-D holes is appropriate for intuitive understanding of homology. Take a torus for example: its 1st homology $H\_1$ is generated by a circle along the torus (the "hole" in this case it the dohnut hole), and a circle across the torus (now the "hole" is the void inside the dohnut surface). The connection between the "holes" and homology generators is not intuitive. More importantly, homology is innate to the manifold, not its embedding, so there may be no holes to speak of.


I'd recommend to look intuitively at $k$th homology $H\_k$ classes that are not zero as embedding of an oriented $k-$manifold $V^k$ into your manifold $M^n$ that cannot be contracted into a point along $M^n$, although I'm sure others would promptly correct me. [Prompt correction: $V^k$ represents zero in homology if it is the boundary of a $(k{+}1)$-manifold in $M$.] Two embeddings of $V\_1^k$ and $V\_2^k$ represent the same class if there is an oriented manifold with boundary $W^{k+1}$ embedded in $M^n$ such that its boundary consists of $V\_1$ and $V\_2$ with one of them having opposite orientation.


As for cohomology classes $H^k$, they are dual to $H\_k$ in linear algebra sense: elements of $H^k$ are linear functionals $w:H^k\to R$. 


IMO the best way to look at $H^k$ is from DeRham viewpoint, where elements of $H^k$ are represented by differential $k-$forms. The duality between $H^k$ and $H\_k$ is straightforward: for $w\in H^k$ and $V\in H\_k$ $w(V)=\int\_V w $.


EDIT: Based on HJRW's comments I've got to change the above description of homology groups to differentiate from homotopy ones.


The core idea in homology is the notion of two embeddings of $V^k\_i$ in $M^n$ being homologous, that is, equivalent under the relation describer in the 2nd paragraph of this answer. In particular, if $V^k\_1$ is homologous to $V^k\_2$, and $V^k\_2$ is contractible, then homology class $[V^k\_1]$ represented by $V^k\_1$ is also $0$, even if $V\_1^k$is not contractible along $M^n$. 


$H\_k$ is naturally a group: union of embeddings defines the sum, and reversal of orientation negates the homology class. Moreover, $H\_k$ is a commutative group, unlike $\pi\_1$, precisely because the equivalence relation is more flexible than homotopy. There are other nice features of $H\_k$ not present in $\pi\_k$, for example $H\_k(M^n)=0$ for $k>n$, etc. It's often useful to take embeddings with coefficients in a ring other than $Z$; to simlify the following let's assume in the following homology with real coefficients.


A bit more on duality now. Suppose that $M^n$ is a **compact** manifold, and $V^k$ and $W^{n-k}$ are "nice enough" embeddings in general position to each other. Count their intersections with the sign that corresponds to whether or not the "combined" orientation of the tangents at the intersection point coincides with $M^n$ orientation. This leads to the map $(V^k,W^{n-k})\to R$. It turns out that this maps depends only on the embeddings' homology classes $[V^k]$ and $[W^{n-k}]$. This makes $H^{n-k}$ dual, in linear algebra sense, to $H^k$ (disclaimer #2: we are using real coefficients). This is known as Poincare duality.


Recall now the definition of cohomology as dual to homology and you get Poincare isomorphism between $H^k$ and $H\_{n-k}$. Given that isomorphism a natural question arises why do we need to define cohomology at all, wouldn't homology suffice? Well there are a few answers to that. My favourite is that cohomology has a very useful product operation that makes it into a ring. From DeRham viewpoint the product of cohomology classes corresponds to the wedge product of the corresponding differential forms. And that ring structure opens a treasure box of opportunities...


