NullPointerException, Collections not storing data?

Ah. Your Hydro class is completely wrong. You're assigning the parameters to the uninitialised members e.

G public Hydro(String name, double starttime, double increment, double p) { name = H_NAME but H_NAME is uninitialised. You need to reverse these e. G public Hydro(String name, double starttime, double increment, double p) { H_NAME = name Some hints: write a toString() method for each class, so you can print it out meaningfully declare your method parameters as final if you don't expect them to change declare your member variables to be final if you expect your class to be immutable (unchanging) investigate unit tests and JUnit In the above, 1. Makes debugging easier 2.

And 3. Means that the compiler will prevent you from the (all too common) mistake above (try preceeding your method parameters with final and see what happens!) 4. Will force you to test at a low level and keep your code correct For debugging purposes it's useful to only deference one reference at a time.

This helps you identify unexpected null references e.g. If the following gives a NullPointerException a.getB().getC().getD() which of a getB() getC() gave the null reference? Dereferencing one per line is more verbose but will give you much more info (object purists will object to the above and refer you to the Law Of Demeter I shall ignore that for this example).

Ah. Your Hydro class is completely wrong. You're assigning the parameters to the uninitialised members.E.g.

Public Hydro(String name, double starttime, double increment, double p) { name = H_NAME; but H_NAME is uninitialised. You need to reverse these e.g. Public Hydro(String name, double starttime, double increment, double p) { H_NAME = name; Some hints: write a toString() method for each class, so you can print it out meaningfully declare your method parameters as final if you don't expect them to change declare your member variables to be final if you expect your class to be immutable (unchanging) investigate unit tests and JUnit In the above, 1. Makes debugging easier 2. And 3.

Means that the compiler will prevent you from the (all too common) mistake above (try preceeding your method parameters with final and see what happens!) 4. Will force you to test at a low level and keep your code correct. For debugging purposes it's useful to only deference one reference at a time.

This helps you identify unexpected null references e.g. If the following gives a NullPointerException a.getB().getC().getD() which of a, getB(), getC() gave the null reference? Dereferencing one per line is more verbose but will give you much more info (object purists will object to the above and refer you to the Law Of Demeter - I shall ignore that for this example).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions