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

A physicist confesses that the electron is round and that Jesus rose from the dead. (Bengali)

একজন পদার্থবিজ্ঞানী স্বীকার করেন যে ইলেকট্রন গোলাকার এবং যিশু মৃতদের মধ্য থেকে পুনরুত্থিত হয়েছিলেন। আমার নিজের বিশ্বাস প্রমাণ দ্বারা প্রভাব...