Created
May 20, 2017 08:53
-
-
Save Burdzi0/80c87dff17b547cbef2a0c8d8720997c to your computer and use it in GitHub Desktop.
Example 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package generics.ograniczony.argument.wieloznaczny; | |
/** | |
* Created by burdzi0 on 20.05.17. | |
*/ | |
public class BoundedWildcard { | |
static void showXY(Coords<?> c) { | |
System.out.println("Współrzędne X i Y: "); | |
for (int i = 0; i < c.coords.length; i++) { | |
System.out.println(c.coords[i].x + " " + c.coords[i].y); | |
System.out.println(); | |
} | |
} | |
static void showXYZ(Coords<? extends ThreeD> c) { | |
System.out.println("Współrzędne X, Y i Z: "); | |
for (int i = 0; i < c.coords.length; i++) { | |
System.out.println(c.coords[i].x + " " + c.coords[i].y + " " + c.coords[i].z); | |
System.out.println(); | |
} | |
} | |
static void showXYZT(Coords<? extends FourD> c) { | |
System.out.println("Współrzędne X, Y, Z i T: "); | |
for (int i = 0; i < c.coords.length; i++) { | |
System.out.println(c.coords[i].x + " " + c.coords[i].y + " " + c.coords[i].z + " " + c.coords[i].t); | |
System.out.println(); | |
} | |
} | |
public static void main(String[] args) { | |
TwoD td[] = { | |
new TwoD(2, 3), | |
new TwoD(5, 6), | |
new TwoD(18, -24), | |
new TwoD(-1, -23) | |
}; | |
Coords<TwoD> tdlocs = new Coords<TwoD>(td); | |
System.out.println("Zawartość tdlocs."); | |
showXY(tdlocs); | |
//showXYZ(tdlocs); | |
//showXYZT(tdlocs); | |
FourD fd[] = { | |
new FourD(1, 2, 3, 4), | |
new FourD(-3, -5, -7, -9), | |
new FourD(15, 22, 34, 9), | |
new FourD(12, 45, 78, 32) | |
}; | |
Coords<FourD> fdlocs = new Coords<FourD>(fd); | |
System.out.println("Zawartość fdlocs."); | |
showXY(fdlocs); | |
showXYZ(fdlocs); | |
showXYZT(fdlocs); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment