Powered by Blogger.

Write a Java Program using This Reference - About Java

Java Program using This Reference:

In Java technology, this keyword is used to resolved ambiguity between instance variables and parameters. It is also used to pass the current object as a parameter to another method.

This Reference Program:

 public class AddNumbers{
 private int num1,num2,result;

 public AddNumbers(int num1,int num2){
 this.num1 = num1;
 this.num2 = num2;
 }

 public void add(){
 result=num1+num2;
 System.out.println(”Result is:”+result);
 }

 public static void main(String[]args){
 AddNumbers addnum = new AddNumbers(10,20);
 addnum.add();
  }
 }

2 comments:

  1. Pretty good post. I just came across your site and wanted to say that I’ve really enjoyed reading your posts. In any case I’ll be subscribing to your feed and I hope you will keep a good work!Cheer!

    sap online training
    software online training
    sap sd online training
    hadoop online training
    sap-crm-online-training

    ReplyDelete
  2. This is one awesome blog article. Much thanks again.
    I really enjoy the blog.Much thanks again. Really Great.


    oracle online training
    sap fico online training
    dotnet online training
    qa-qtp-software-testing-training-tutorial

    ReplyDelete