best-practice.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="generator" content="Asciidoctor 2.0.15">
  8. <title>Best-Practice</title>
  9. <link rel="stylesheet" href="css/site.css">
  10. <link href="css/custom.css" rel="stylesheet">
  11. <script src="js/setup.js"></script><script defer src="js/site.js"></script>
  12. </head>
  13. <body class="article toc2 toc-left"><div id="banner-container" class="container" role="banner">
  14. <div id="banner" class="contained" role="banner">
  15. <div id="switch-theme">
  16. <input type="checkbox" id="switch-theme-checkbox" />
  17. <label for="switch-theme-checkbox">Dark Theme</label>
  18. </div>
  19. </div>
  20. </div>
  21. <div id="tocbar-container" class="container" role="navigation">
  22. <div id="tocbar" class="contained" role="navigation">
  23. <button id="toggle-toc"></button>
  24. </div>
  25. </div>
  26. <div id="main-container" class="container">
  27. <div id="main" class="contained">
  28. <div id="doc" class="doc">
  29. <div id="header">
  30. <h1>Best-Practice</h1>
  31. <div id="toc" class="toc2">
  32. <div id="toctitle">Table of Contents</div>
  33. <span id="back-to-index"><a href="index.html">Back to index</a></span><ul class="sectlevel1">
  34. <li><a href="#_泛型">1. 泛型</a></li>
  35. </ul>
  36. </div>
  37. </div>
  38. <div id="content">
  39. <div class="sect1">
  40. <h2 id="_泛型"><a class="anchor" href="#_泛型"></a>1. 泛型</h2>
  41. <div class="sectionbody">
  42. <div class="dlist">
  43. <dl>
  44. <dt class="hdlist1">使用场景</dt>
  45. <dd>
  46. <p>属性不能使用具体类型,也不能使用接口类型或者父类,因为使用接口或父类就无法再调用实现类的方法除非进行类型强转</p>
  47. </dd>
  48. <dt class="hdlist1">限定类型参数</dt>
  49. <dd>
  50. <p>泛型方法中参数是集合或者迭代器的类型要注意使用extends或super限定类型,否则泛型的子类无法作为参数,遵循PECS(producer-extends,consumer-super)原则</p>
  51. </dd>
  52. </dl>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <div id="footer">
  58. <div id="footer-text">
  59. Last updated 2024-03-18 05:44:42 UTC
  60. </div>
  61. </div>
  62. <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
  63. <script>
  64. if (!hljs.initHighlighting.called) {
  65. hljs.initHighlighting.called = true
  66. ;[].slice.call(document.querySelectorAll('pre.highlight > code')).forEach(function (el) { hljs.highlightBlock(el) })
  67. }
  68. </script>
  69. <script src="https://utteranc.es/client.js"
  70. repo="pxzxj/articles"
  71. issue-term="title"
  72. label="utteranc"
  73. theme="github-light"
  74. crossorigin="anonymous"
  75. async>
  76. </script>
  77. </div>
  78. </div>
  79. </div>
  80. </body>
  81. </html>