Hi my dear friend today my aim is to show you about the methods in java and how to access them using Opp concepts.
Come with me......
Read the comments I have given below and get the idea of opp.Run the code and have the output...
Find what are Objects in Opp..Flowing show you about the creating objects in Opp.
Come with me......
Read the comments I have given below and get the idea of opp.Run the code and have the output...
Find what are Objects in Opp..Flowing show you about the creating objects in Opp.
public class first{ //My class name is first
String name; //Here I declare the variable but not assign any value.So it do not use any memory space.
void setName(String studentName){ //Here I am create a set method.This method return //nothing.So void data type is used.
name=studentName;
}
String getName(){ //Here I create get method.It return a string.
return name;
}
public static void main(String args[]){
first myfirst=new first(); //This is how we create Objects.This is called instiating.
myfirst.setName("Manuja");
System.out.println(myfirst.getName());//This is how we access the getName method using // newly created object.
}
}
Now it is All over.....