main, abs, read, and other static Methods

Certain methods pose a bit of a problem:

static Methods to the Rescue

Static methods

Static Data - State for Static Methods

Static variables

read Methods

Need to create the object before can invoke its methods

class Name {
	Name(String last, String first) {
		this.last = last;
		this.first = first;
	}
	
	static Name read(BufferedReader br) {
		String line = br.readLine();
		if (line == null) return null;	// No more names in file
		line = line.trim();
		
		int pos = line.indexOf(",");
		String last = line.substring(0, pos);
		line = line.substring(pos+1).trim();
		
		pos = line.indexOf(",");
		String first = line.substring(0, pos);
		line = line.substring(pos+1).trim();

		return new Name(last, first);
	}