CodeGym/Java Course/Module 2: Java Nkyem/該級別的附加課程

該級別的附加課程

開放

Java 中的泛型是什麼?

在本課中,我們討論泛型。或者更確切地說,關於您在深入研究泛型時需要了解的基礎知識:什麼是泛型以及您為什麼需要它們。這個話題很重要,你一定要理解它。向前!

貓的仿製藥

泛型是一個很好的工具,可以幫助開發人員向編譯器提示額外信息以確保類型安全和靈活性。這篇由 CodeGym 社區成員撰寫的深度文章圍繞“泛型”又進行了一次探討。

類型擦除

本課專門介紹泛型的一些特性以及使用它們時出現的陷阱。因為在創建語言時泛型不是 Java 的一部分,所以添加了類型擦除。那是什麼?我們會想辦法的。

泛型中的通配符

通配符是泛型的一個非常重要的特性,絕對值得單獨上一課。這是一個有趣而簡單的話題。你會愛上它的:)

使用泛型時使用可變參數

將可變參數與泛型一起使用會導致相當不愉快的後果——堆污染。在本課中,我們結束了對 Java 中泛型的各種特性的討論。

4
任務
Java Core,  等級 5課堂 4
上鎖
Something superfluous
Our program is once again full of unnecessary lines of code. Let's correct this blunder by removing all the extra methods, so that the program displays text (and only the text) that corresponds to the task conditions. By the way, you need to get used to this. Junior developers' special ability to create unnecessary code is pretty annoying to senior developers.
8
任務
Java Core,  等級 5課堂 4
上鎖
OOP: Method overloading
Let's display matrices in different ways, however we want. OOP gives us a wonderful tool for this: method overloading. Overload the printMatrix method in 8 different ways. You should end up with 10 different printMatrix methods.
4
任務
Java Core,  等級 5課堂 4
上鎖
OOP: Method overloading - Eliminating the superfluous
Not every overloaded method is useful. And so it is in this program. Look at the code and think about which implementation of the print method will be called. Then remove all the superfluous implementations of the method - and you're done.
4
任務
Java Core,  等級 5課堂 4
上鎖
Man or woman?
Something in this program isn't right... It seems to display the names of men, but not those of women. Put an end to the discrimination: change the printName method so that it runs for both man and woman. The method should have a single implementation.
4
任務
Java Core,  等級 5課堂 4
上鎖
Be gone, all that is unnecessary!
Again, we have extra lines in a program. They've resulted in a bug, because the program tries to call the add method for cases for which it is not implemented. We won't override the superfluous add methods this time. We'll do something simpler: delete the lines for which there is no implementation.
留言
  • 受歡迎
你必須登入才能留言
此頁面尚無留言