java:generic_interface_example
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| java:generic_interface_example [2016/04/15 09:04] – gthanos | java:generic_interface_example [2020/02/25 09:34] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Παράδειγμα | + | ====== Παράδειγμα |
| - | Ας επανέλθουμε στο παράδειγμα [[java:interfaces# | + | Ας επανέλθουμε στο παράδειγμα [[java:interface_as_data_type|χρήσης των interfaces ως τύπους δεδομένων]] και ας αλλάξουμε ελαφρά το interface MyComparable ώστε να περιέχει και την μέθοδο isEqual που ελέγχει την ισότητα. |
| <code java MyComparable.java> | <code java MyComparable.java> | ||
| Line 516: | Line 516: | ||
| </ | </ | ||
| + | Το μήνυμα που εμφανίζει ο compiler είναι το παρακάτω | ||
| + | <code txt compiler-error.txt> | ||
| + | CompareObjects.java: | ||
| + | System.out.println(" | ||
| + | ^ | ||
| + | required: TwoDShape, | ||
| + | found: Rectangle, | ||
| + | reason: actual argument Cuboid cannot be converted to TwoDShape by method invocation conversion | ||
| + | where T is a type-variable: | ||
| + | T extends MyComparable< | ||
| + | </ | ||
| - | + | | Προηγούμενο : [[ : | |
| - | + | ||
| - | + | ||
java/generic_interface_example.1460711057.txt.gz · Last modified: 2016/04/15 08:04 (external edit)
