我讀some教程中我碰到條款哪裏傳來類似
Key<Car> rootKey = new Key<Car>(Car.class, 959);
是什麼<Car>
意味着這個代碼?爲什麼這裏使用這些「<」符號?請幫忙。java中的ClassName <Something >中的<Something>是什麼意思?
1
A
回答
3
你的代碼片段代表一個泛型類型說明符。您可以使用Car以外的類型實例化Key,並且它的方法在編譯時對該變量是類型安全的。
例如,下面的語句是類型安全的,就像你的例子是:
Key<String> rootKey = new Key<String>(String.class, "someString");
更多信息請參見http://docs.oracle.com/javase/tutorial/java/generics/gentypes.html。
1
0
- 車是你的 「汽車-Object類」 你傳遞
- <>符號用於指定你想爲你的 Key類對象的類型。
相關問題
- 1. 方法<ClassName>是什麼意思?
- 2. 什麼是std :: _ Bind <std :: _ Mem_fn <void(ClassName :: *)()>(ClassName *)>是什麼意思? (C++)
- 3. Puppet中'if $ variable {}'的意思是什麼?</p> <pre><code>if $variable { do something } </code></pre> <p>這是什麼意思:
- 4. 在java中代表<< or > >>是什麼意思?
- 5. 在Java中,>>或<<是什麼意思?
- 6. Ruby中的<>是什麼意思?
- 7. <+>是什麼意思?
- 8. <>是什麼意思?
- 9. <>是什麼意思?
- 10. {< >}是什麼意思?
- 11. 這是什麼意思(計算中的<< and > >>)?
- 12. Java中的$(「something」)是什麼意思?
- 13. Ruby中的「<< - 」是什麼意思?
- 14. C++中的「(」<<「)是什麼意思?
- 15. python中的`<-`, `> -`,`<+`, `> +`是什麼意思?
- 16. Erlang代碼中的<<>>是什麼意思?
- 17. Javascript中「>>」和「<<」是什麼意思?
- 18. 「$ <$ <CONFIG:Debug>:Release>」在cmake中是什麼意思?
- 19. class myClass <String>是什麼意思?
- 20. List <JAXBElement <?是什麼?擴展SomeClassName >>的意思是?
- 21. SBT中`<< =`是什麼意思?
- 22. << - 在R中是什麼意思?
- 23. THREE.Camera.prototype.lookAt</ <() -</ <是什麼意思?
- 24. ArrayList <Number>是什麼意思?
- 25. <ice:outputText value =「#{exam.testName}」/>是什麼意思?
- 26. <String,String>是什麼意思?
- 27. Java中的<E>是什麼意思?
- 28. ASP.NET - <%@和<asp:Panel?是什麼意思?
- 29. <Object>在地圖上<Object>是什麼意思?
- 30. 「<<" and ">>」是什麼意思在c + +的cout/cin?
歡迎來到泛型的世界。 – 2012-04-03 21:35:28
http://docs.oracle.com/javase/tutorial/java/generics/generics.html – Adam 2012-04-03 21:35:49
可能的重複[< and >是什麼意思,例如implements Comparable?](http://stackoverflow.com/questions/450520 /什麼-DO和均值 - 例如-AS-工具,comparablebiginteger) –
Tomalak
2012-04-03 21:35:59