java:member_initialization
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| java:member_initialization [2022/02/24 05:34] – [Αρχικοποίηση των μελών της κλάσης] gthanos | java:member_initialization [2022/02/24 12:39] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 168: | Line 168: | ||
| int getArea() { | int getArea() { | ||
| | | ||
| - | } | ||
| - | |||
| - | // Move rectangle origin by x,y | ||
| - | void move(int dx, int dy) { | ||
| - | origin.setX( origin.getX() + dx ); | ||
| - | origin.setY( origin.getY() + dy ); | ||
| } | } | ||
| | | ||
| - | String | + | String |
| - | return " | + | return " |
| } | } | ||
| | | ||
| - | static void main(String []args) { | + | |
| System.out.println(" | System.out.println(" | ||
| Point p = new Point(10, | Point p = new Point(10, | ||
| + | | ||
| Rectangle rectOne = new Rectangle(30, | Rectangle rectOne = new Rectangle(30, | ||
| - | System.out.println(rectOne.toString(" | ||
| System.out.println(" | System.out.println(" | ||
| + | System.out.println(rectOne.description(" | ||
| System.out.println(" | System.out.println(" | ||
| } | } | ||
| Line 200: | Line 195: | ||
| initialize objectId in block, id: 100 | initialize objectId in block, id: 100 | ||
| Initialized object id in constructor, | Initialized object id in constructor, | ||
| - | [rectOne.1] Width: 30, Height: 40, Origin: [Point xPos:10, yPos:20] | ||
| ------------------------------- | ------------------------------- | ||
| + | [rectOne] (id: 1) Width: 30, Height: 40 | ||
| Number of Rectangles: 1 | Number of Rectangles: 1 | ||
| </ | </ | ||
| Line 214: | Line 209: | ||
| </ | </ | ||
| - | |Προηγούμενο: | + | |Προηγούμενο: |
| - | + | ||
| - | + | ||
| - | + | ||
java/member_initialization.1645680880.txt.gz · Last modified: 2022/02/24 05:34 by gthanos
