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@4dd340a3
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@22326cba, com.xpn.xwiki.api.Object@1c8038e0, com.xpn.xwiki.api.Object@261608be, com.xpn.xwiki.api.Object@7098057a, com.xpn.xwiki.api.Object@c8fc656, com.xpn.xwiki.api.Object@33263e8b, com.xpn.xwiki.api.Object@13d431e9, com.xpn.xwiki.api.Object@5018c22a, com.xpn.xwiki.api.Object@9737c7b]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor