Monday 15 September 2014

This Key Word in Java

Structure of the Problem Requirements 

In this problem we will learn how to use this in Java programs .The (this) keyword can be used inside the class or methods to referrer the object whose methods or constructor is being called. In variables handling (this ) keyword is very useful. Here is the source code of this problem which help you in better inderstanding.

SOURCE CODE




class ThisDemo
{
public static void main(String args[])
{
example e=new example();
e.Mul(30,20);
e.display();
}
}
//Sub Class
public class example
{
int x,y,z;
void Mul(int x,int y)
{
this.x=x;
this.y=y;
z=x*y;
}
void display()
{
System.out.println("Multiplication is :"+z);
}
}

                      Output of the Program


The use of this keyword
The use of this keyword in Java


Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment