i try to extract glyphIndex from cmap tables ,I'd like to ask about if a character code maybe appear in many cmap tables for Ex: a character code can appear in both cmap0 and cmap4 tables? and if this case happened then should the glyphIndex of the character be extracted from the higher cmap
Yes, a character code may appear in multiple cmap subtables.
See the OpenType spec: http://www.microsoft.com/Typography/otspec/cmap.htm
Which cmap subtable you would use to access the character would depend on your particular needs. What kind of codepoint are you trying to look up the glyph with? You say "cmap0" and "cmap4" but you don't specify whether the 0 and 4 refer to platform, encoding, or format.
I'm going to guess that you are referring to format 0 and format 4. First, I would say that one would normally pick a cmap based first on platform/encoding, and only secondarily on format.
Cmap format 0 is an old Apple format, limited to 256 encoded glyphs, seen in conjunction with platform=specific encoding(s), notably MacRoman.
Format 4 is one of several ways of representing Unicode codepoints, with the limitation that it can only deal with codepoints in the Basic Multilingual Plane or BMP.