Refactoring contributed by Marian Vittek
void printValues() {
for (int i = 0; i < people.length; i++) {
System.out.println(people[i].name+" has salary "+people[i].salary);
}
}
public static void main(String args[]) {
...
printValues();
}

void printValues(PrintStream outfile) {
for (int i = 0; i < people.length; i++) {
outfile.println(people[i].name+" has salary "+people[i].salary);
}
}
public static void main(String args[]) {
...
printValues(System.out);
}
The original function is using a static variable, but you wish either to reuse the function in new project (not containing the static variable) or reuse the function in the same project but in more general context.