Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Pamela Baker   on Aug 08 In Java Category.

Question Answered By: Stacie Martin   on Aug 08

class Student
public String name = "John Doe";
public int type = 0;
public int tutor = 2;

public Student(String n, int s, int t)
this.name = n;
this.type = s;
this.tutor = t;


This refers to the current class.

It is more useful when inheriting as you can call an inherited method
using this, which would have been quite hard to do if this did not

What I have done in the above example  is to set attributes to



This Question has 1 more answer(s). View Complete Question Thread

Didn't find what you were looking for? Find more on can somebody please explain the function of "this" Or get search suggestion and latest updates.