Skip to content

Instantly share code, notes, and snippets.

@smamran
Created August 21, 2015 04:06
Show Gist options
  • Save smamran/ecd6e43d4a54696d035b to your computer and use it in GitHub Desktop.
Save smamran/ecd6e43d4a54696d035b to your computer and use it in GitHub Desktop.
Usage of This keyword..
package com.netcse.java;
public class Main {
int id;
String name;
Main(int i, String n){
id = i;
name = n;
}
void setData(int id, String name){
this.id = id;
this.name = name;
}
void getData(){
System.out.println(id + " -> " + name);
}
public static void main(String[] args) {
Main mn = new Main(10, "ten");
mn.setData(20, "twenty");
mn.getData();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment