Java Tutorial/Class Definition/This

Материал из Java эксперт
Версия от 08:00, 1 июня 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

The this Keyword

You use the this keyword from any method or constructor to refer to the current object.



   <source lang="java">

public class Box {

   int length;
   int width;
   int height;
   public Box(int length, int width, int height) {
       this.length = length;
       this.width = width;
       this.height = height;
   }

}</source>