This Keyword PDF
This Keyword PDF
Example 1
Program where this keyword is not required
class Student
{
int rollno;
String name;
float fee;
Example 2
Understanding the problem without this keyword
Let's understand the problem if we don't use this keyword by the example given below:
class Student
{
int rollno;
String name;
float fee;
class Student
{
int rollno;
String name;
float fee;
void display()
{System.out.println(rollno+" "+name+" "+fee);}
class TestThis2{
public static void main(String args[]){
Student s1=new Student(111,"ankit",5000f);
Student s2=new Student(112,"sumit",6000f);
s1.display();
s2.display();
}}