Sunday, April 8, 2018

Using This Keyword in Java

Here is a short and simple program to demonstrate the user of this keyword in Java.

I am currently accepting programming, IT consulting work and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Program Listing


thisDemo.java



package oop_java;
/**
 * NetBeans IDE 8.2
 * @author Mr. Jake R. Pomperada
 * March 30, 2018  Friday
 * Bacolod City, Negros Occidental
 */
class thisDemo {
    
   String username;
   
void Greetings(String username) {
     this.username= username; // “this” represents the “person”
     System.out.println("Hello "+ this.username );
}

public static void main(String[ ] args) {
thisDemo person = new thisDemo();
System.out.println("this Keyword in Java Demonstration");
person.Greetings("Julianna Rae F. Pomperada");
System.out.println("\n");  
   }
}

No comments:

Post a Comment