0
我試圖訪問數組中的元素,但我不斷收到錯誤。 這裏是我的數組聲明: String[] tTest = ["A", "B", "C"]
我試過索引:print tTest[0]
和功能getAt:print tTest.getAt(0)
但它沒有奏效。 有人可以幫我嗎? Thx。如何訪問數組中的元素?
我試圖訪問數組中的元素,但我不斷收到錯誤。 這裏是我的數組聲明: String[] tTest = ["A", "B", "C"]
我試過索引:print tTest[0]
和功能getAt:print tTest.getAt(0)
但它沒有奏效。 有人可以幫我嗎? Thx。如何訪問數組中的元素?
例如:
println tTest[0]
- 打印的特定元素(甲),int nn = tTest.size()
- 以獲得陣列()的大小。println tTest.getAt(2)
也工作。我使用了Groovy Web控制檯http://groovyconsole.appspot.com/
你得到了哪一個完整的和確切的錯誤? –
「Scripts not allowed to use staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods getAt java.lang.Object []」and「unclassified method java.lang.String [] getAt java.lang.Integer」 – Emile
我發現我的錯誤......這不是我對元素的訪問,而是我對該元素的打印......謝謝@JBNizet – Emile