Skip to content

Instantly share code, notes, and snippets.

@rishi93
Created October 29, 2015 08:33
Show Gist options
  • Save rishi93/9fed2dbc9db2fe633394 to your computer and use it in GitHub Desktop.
Save rishi93/9fed2dbc9db2fe633394 to your computer and use it in GitHub Desktop.
Use of private data members
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