java:objects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
java:objects [2016/02/18 13:58]
doufexi fixed constructor and calls, added observation re: field initialization in constructor, added toc link, fixed minor typos
java:objects [2017/02/16 09:21]
gthanos
Line 1: Line 1:
-====== Δημιουργώντας Αντικείμενα ======+====== Δημιουργία Αντικειμένων ======
  
 Μέχρι τώρα αναφέραμε στην [[ oop:​introduction | "​Εισαγωγή στον Αντικειμενοστραφή Προγραμματισμό"​ ]] ότι η κλάση είναι το βασικό σχέδιο μέσα από το οποίο δημιουργούνται επιμέρους αντικείμενα που φέρουν τα χαρακτηριστικά της κλάσης. Επίσης,​ δείξαμε πως ορίζουμε μία κλάση μέσα από παραδείγματα,​ αλλά δεν δείξαμε πως δημιουργούμε αντικείμενα από τις κλάσεις που ορίσαμε. ​ Μέχρι τώρα αναφέραμε στην [[ oop:​introduction | "​Εισαγωγή στον Αντικειμενοστραφή Προγραμματισμό"​ ]] ότι η κλάση είναι το βασικό σχέδιο μέσα από το οποίο δημιουργούνται επιμέρους αντικείμενα που φέρουν τα χαρακτηριστικά της κλάσης. Επίσης,​ δείξαμε πως ορίζουμε μία κλάση μέσα από παραδείγματα,​ αλλά δεν δείξαμε πως δημιουργούμε αντικείμενα από τις κλάσεις που ορίσαμε. ​
Line 36: Line 36:
 public class Rectangle { public class Rectangle {
     ​     ​
-  // the Rectangle class has 3 fields+  // fields
   private int width;   private int width;
   private int height;   private int height;
   private Point origin;   private Point origin;
     ​     ​
-  // the Rectangle class has one constructor+  // constructors
   public Rectangle(int initWidth, int initHeight, Point initOrigin) {   public Rectangle(int initWidth, int initHeight, Point initOrigin) {
     width = initWidth;     width = initWidth;
Line 54: Line 54:
   }   }
     ​     ​
-  // the Rectangle class has 3 methods+  // methods
   public void setWidth(int newWidth ) {   public void setWidth(int newWidth ) {
     width = newWidth;     width = newWidth;
java/objects.txt · Last modified: 2018/02/16 16:03 by gthanos