Java Tutorials_Generics(java泛型)

來源:互聯網
上載者:User

標籤:java tutorials_gener

Lesson: Generics (Updated)

In any nontrivial software project, bugs are simply a fact of life. Careful planning, programming, and testing can help reduce their pervasiveness, but somehow, somewhere, they‘ll always find a way to creep into your code. This becomes especially apparent as new features are introduced and your code base grows in size and complexity.

Fortunately, some bugs are easier to detect than others. Compile-time bugs, for example, can be detected early on; you can use the compiler‘s error messages to figure out what the problem is and fix it, right then and there. Runtime bugs, however, can be much more problematic; they don‘t always surface immediately, and when they do, it may be at a point in the program that is far removed from the actual cause of the problem.

Generics add stability to your code by making more of your bugs detectable at compile time. After completing this lesson, you may want to follow up with the Generics tutorial by Gilad Bracha.

Java泛型

在任何瑣碎的軟體項目中,bugs是一個簡單的生活事實。你小心的計劃,編程,並且加以測試能夠協助你減少普通的錯誤,但是不管怎樣,也不論在哪些地方,這些bugs總會尋找一個方式浸入進你的代碼,當你新的功能特性被引入和你的代碼在數量和複雜的增長的時候是尤其的明顯。

幸運的是,有一些代碼是更容易被檢測到比起其他的代碼,例如:編譯時間的bugs在早期就能夠被檢測到,你能夠利用編譯的錯誤資訊去思考問題出現在哪兒,並且修複他們,然後,運行時的bugs是非常棘手的問題,他們不總立即是出現在表面,當它們啟動並執行時候可能,在程式的啟動並執行時候的出現的那一點問題早已偏離了實際問題的原因

泛型給你的代碼添加的健壯性通過做更多編譯時間檢查,在學習這節課之後,你可能相應會一探究竟探究泛型指南手冊


Java Tutorials_Generics(java泛型)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.