CodeGym/Java kurs/Modul 2: Java Core/Ytterligare lektioner för nivån

Ytterligare lektioner för nivån

Tillgängliga

Vad är generika i Java?

I den här lektionen pratar vi om generika. Eller snarare, om grunderna som du behöver veta när du dyker in i generika: vad generika är och varför du behöver dem överhuvudtaget. Ämnet är mycket viktigt, och du måste definitivt förstå det. Fram!

Generika för katter

Generika är ett utmärkt verktyg för att hjälpa utvecklare att tipsa om ytterligare information till kompilatorn för typsäkerhet och flexibilitet. Denna djupgående artikel , skriven av en medlem av CodeGym-communityt, tar ytterligare ett varv kring "generics".

Typ radering

Den här lektionen ägnas åt några egenskaper hos generika samt fallgropar som uppstår när man arbetar med dem. Eftersom generika inte var en del av Java när språket skapades, har typen radering lagts till. Vad är det? Vi kommer att hitta en lösning.

Jokertecken i generika

Jokertecken är en mycket viktig egenskap hos generika och förtjänar definitivt en separat lektion . Detta är ett intressant och enkelt ämne. Du kommer att älska det :)

Att använda varargs när man arbetar med generika

Att använda varargs med generika kan leda till ganska obehagliga konsekvenser - högföroreningar. I den här lektionen avslutar vi vår diskussion om olika funktioner hos generika i Java.

4
Uppgift
Java Core,  nivålektion
Låst
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
Uppgift
Java Core,  nivålektion
Låst
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
Uppgift
Java Core,  nivålektion
Låst
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
Uppgift
Java Core,  nivålektion
Låst
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
Uppgift
Java Core,  nivålektion
Låst
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.
Kommentarer
  • Populär
  • Ny
  • Gammal
Du måste vara inloggad för att lämna en kommentar
Den här sidan har inga kommentarer än