English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

// Constructor

public IntSet(int size)
{
this.size = size;
array = new int[size];
length = 0;
}

2007-02-19 08:07:55 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

in an object 'this' the size is a method
however, your constructor doesnt make sence because it is comming in as an integer, and you are using it as an instance variable of an object.

2007-02-19 08:18:36 · answer #1 · answered by Anonymous · 0 0

When an object is instantiated, all the instance variables and methods belong to that object. When we are inside the object in implicit, hence there is no need to explicitly use the dot operator to refer to it. If we want, we can use the this parameter to refer to that object itself.

ex
public class Student
{
private String name;
private int test;
public void writeOutput ()
{
System.out.println ("Name = " + name);
This is the same as
System.out.printlnl ("Name = " + this.name);
}
}//end of class

2007-02-19 16:24:23 · answer #2 · answered by jhn_grz 3 · 1 0

the dot means that 'size' is a property of 'this'. Looks like the object 'this' is getting it's property 'size' set to the value of 'size'

Look up object oriented programming and java.

2007-02-19 16:12:11 · answer #3 · answered by Roger M 1 · 0 0

fedest.com, questions and answers