QUOTE(pbl @ 25 Aug, 2008 - 07:25 PM)

QUOTE(marcel.brown @ 25 Aug, 2008 - 07:02 PM)

I am just trying to master methods. I don't want the methods with the object. I want it break down how methods work with void methods and return value method. Can you give me a good example and explain whats happening? thanks in advance
Usually methods go with objects... static methods are the exception
CODE
class Person {
String name;
int age;
// method get age
int getAge() {
return age;
}
// method get name
String getName() {
return name;
}
}
The 2 previous methods are used to retreive age and name from a Person object
Now a static method can be used to return "static" elements common to all Persons
CODE
class Person {
static String[] fields = {"Name", "age"};
static String[] getPersonFields() {
return fields;
}
I am talking about like write a program the regular way and write and then write it in a method and break it down. Explain whats happening in the program...
QUOTE(pbl @ 25 Aug, 2008 - 07:25 PM)

QUOTE(marcel.brown @ 25 Aug, 2008 - 07:02 PM)

I am just trying to master methods. I don't want the methods with the object. I want it break down how methods work with void methods and return value method. Can you give me a good example and explain whats happening? thanks in advance
Usually methods go with objects... static methods are the exception
CODE
class Person {
String name;
int age;
// method get age
int getAge() {
return age;
}
// method get name
String getName() {
return name;
}
}
The 2 previous methods are used to retreive age and name from a Person object
Now a static method can be used to return "static" elements common to all Persons
CODE
class Person {
static String[] fields = {"Name", "age"};
static String[] getPersonFields() {
return fields;
}
I am talking about like write a program the regular way and write and then write it in a method and break it down. Explain whats happening in the program...