Groovy
Retrieve the first object (index [0]) among all objects attached to this page and of a certain class
obj = doc.getObject('XWiki.XWikiComments')
com.xpn.xwiki.api.Object@1fedce16
Retrieve all objects attached to this page and of a certain class and one of their properties
objs = doc.getObjects('XWiki.XWikiComments')
[com.xpn.xwiki.api.Object@77270f6f, com.xpn.xwiki.api.Object@25667d86, com.xpn.xwiki.api.Object@6bbafb98, com.xpn.xwiki.api.Object@40dbef69, com.xpn.xwiki.api.Object@2742f7c3, com.xpn.xwiki.api.Object@1d983758, com.xpn.xwiki.api.Object@74598195, com.xpn.xwiki.api.Object@204a98e0, com.xpn.xwiki.api.Object@17aaab0]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor