15/11/2014
Assume......Think...
java class == our house Enviroment
in our house we contain no of things like
plates,bowls,glasses,windows,doors,key loker,cycle,bike,car...etc
father,mother,brother,sister,grand fathr,grand mother....etc
as well as in class
variables,methods,method parameters,static variables,access modifiers (public ,private..)
here.....
class{ class is home and { & } compound wall of house
}
if you have friend ,he comes to your house with or without your/gate keeper permission i.e access /or not access
unkown person before coming in to your house ,he should permit from you ....so what here i am saying is
i wann going in to class ,jre(java runtime environment) checks is this class is public or private
example:
public class ABC {
}
//this class will be access your friend/ any unkown person
private class ABC {
}
// no one can not access this class
as well as
public class ABC {
private String name;
// this is variable declaration {String is the declaration data type is group of charecters ex: java is string
here i assign name is java.
//And this is declare as private we can't this variable
name="JAVA";
puclic setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
public static void main(String args[]){
ABC abc=new ABC(); this is instance creation ,and this instance is refferce to abc
abc.name; compile error
System.out.print("we cant access the abc.name value.."+abc.name);
abc.getName(); // now we can get name
}
}
// home is public like class... but bike is private variable like name think in this way....ok
person
in real life if you want to use friends bike....
1st you should get permission from your friend as well as we use getName() method
Think in this way practically.....
IF you really like and understood like and share it.. :) :) :)