Saturday, July 22, 2023

Use of ' this ' keyword in Java

 How to use ' this ' keyword in java?


class A
{
    public int x;
    A()
    {
        x=0;
        System.out.println("Default Constructor");
    }
    A(int x)
    {
        this.x=x;
        System.out.println("I am THIS.X");
    }
}

public class UseofThis{
    public static void main(String[] args) {
        A ob1=new A();
        A ob2=new A(5);
    }
}

No comments:

Post a Comment

Interference in Light vs Quantum States

🔬 The Double-Slit Experiment: Where It All Begins One of the most famous demonstrations of interference is the double-slit experiment. When...