Skip to content

Commit

Permalink
use of this keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
Piyushvishnoi authored Jan 16, 2020
1 parent 7a338dc commit 0dafbcc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions keywords in java/thiskeyword.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class cube
{
Integer width;
Integer depth;
Integer length;
public void area(Integer width,Integer depth,Integer length)
{
this.width=width; //this keyword is used to remove confusion among same name of variables
this.depth=depth;
this.length=length;
System.out.println(width*depth*length);
}
}
public class thiskeyword {
public static void main(String[] args) {

cube c=new cube();
c.area(2,3,4);
}

}

0 comments on commit 0dafbcc

Please sign in to comment.