hi everybody,
i am experimenting with oops concept. first have a look at these coding and then tell me this.
what do i have to do to get the value of an object created. i want to use the get method to get the name, food and quantity, without the use of the created object. i mean i want to make the process independent of how many objects i make so that i can find a value given the name of a person in the object.
when this is done, i want to use this to create filed of a specific doc format for each object created. now when we are using the get method i want to read whats on the object value .
Am i being clear or are thing very confusing, please let me know wht u think so i can clarify myself more.
public class obj {
String name;
String food;
int quantity;
public void set(String ndata, String fdata,int qdata )
{
this.name=ndata;
this.food=fdata;
this.quantity=qdata;
}
public void get()
{
System.out.println( this.name+" "+this.food+" "+this.quantity);
}
public static void main(String[] args) {
obj obj1= new obj();
obj1.set("varun", "burger", 2);
obj obj2= new obj();
obj1.set("roshan", "diet pepsi", 1);
obj obj3= new obj();
obj1.set("aman", "biryani", 2);
obj2.get();
}
}