Created
October 29, 2015 08:33
-
-
Save rishi93/9fed2dbc9db2fe633394 to your computer and use it in GitHub Desktop.
Use of private data members
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class example{ | |
private int data; | |
public example(int d){ | |
data = d; | |
} | |
public int getdata(){ | |
return data; | |
} | |
} | |
public class test{ | |
public static void main(String args[]){ | |
example e1 = new example(5); | |
System.out.println(e1.getdata()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment