this Keyword in Java

this holds the reference of current object. Observe below example: class demo {                 int  x=10;                 void show(int x,demo d1)                 {                                 System.out.println(this.x);                                 System.out.println(d1.x);                                 System.out.println(x);                 }                 public static void main(String…s)                 {                                 demo d1=new demo();                                 d1.show(20,d1);                 } } Output: 10 10 20 In Java by default …

this Keyword in Java Read More »

Classes and Objects in Java

Class Class is the collection of similar type of objects which have some common properties. Class is a concept which is implemented by object. Class is a blueprint of java program from which we create object, then object is instance of class. We can also say that class is a collection of variables and methods. …

Classes and Objects in Java Read More »