Új hozzászólás Aktív témák
-
Drizzt
nagyúr
válasz
Lortech
#10212
üzenetére
Miért nem simán T a paraméter az első add függvényedben, az interface-ben? Ha azt csinálod, akkor azzal meg tudod akadályozni, hogy a "impl1.add(impraw);" illetve a "impl2.add(impraw);" leforduljon. Persze az impraw.add fogad mindenféle típusú interface-et. Aztán ha type mismatch van, akkor futási időben száll el a
paramEnforcerMatrix.add(paramEnforcerVector); sor.public interface ParamEnforcer<T extends ParamEnforcer<T>> {
void add(T other);
}
class MatrixType implements ParamEnforcer<MatrixType> {
@Override
public void add(MatrixType other) {
}
}
class VectorType implements ParamEnforcer<VectorType> {
@Override
public void add(VectorType other) {
}
}
class Tester {
void test() {
MatrixType matrixType = new MatrixType();
ParamEnforcer paramEnforcerMatrix = matrixType;
VectorType vectorType = new VectorType();
ParamEnforcer paramEnforcerVector = vectorType;
matrixType.add(matrixType);
vectorType.add(vectorType);
paramEnforcerMatrix.add(paramEnforcerVector);
}
}
Új hozzászólás Aktív témák
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- GAMER PC - R5 5500/RX 5700 XT 8GB/16GB RAM/500GB SSD/600W/W11 PRO
- GAMER PC - 5 5500/RX 6600 XT 8GB/16GB RAM/512GB SSD
- GAMER PC - Intel i5-14400F/RX 6600 XT 8GB/16GB DDR4/500 GB SSD
- ASUS X571G (Core i5-9300H / Nvidia GTX1650 4GB / 16Gb / 256GB / 15,6" IPS / Win11) Garancia
- Számlával, Garanciával, AMD Ryzen 7 9800X3D
- BESZÁMÍTÁS! ASUS H510M i5 11500 16GB DDR4 512GB SSD RX 7600 8GB Zalman T4 Plus be quiet! 600W
- HIBÁTLAN iPhone 13 256GB Pink -1 ÉV GARANCIA - Kártyafüggetlen, MS3732
- Akció!!! Microsoft Surface Laptop 4 13.5" i7-1185G7 16GB 512GB 1 év garancia
- Akció!!! Lenovo ThinkPad P15 Gen 1 Intel i7-10875H 32GB 1000GB Nvidia Quadro RTX 3000 1 év garancia
- Gamer PC- Számítógép! Csere-Beszámítás! R5 5500 / RX 6700XT 12GB / 16GB DDR4 / 1TB Nvme SSD
Állásajánlatok
Cég: Laptopszaki Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest

