Lu Kim Hui wrote:sorry! edited... the full codes are up there
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Campbell Ritchie wrote:Yes, that is what he means. Enter the following line before line 35 and after line 34:
Lu Kim Hui wrote:but the NPE errors are still the same
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Lu Kim Hui wrote:Erm... because this is an exercise given from my lecturer, and the requirement is reading from the file and store inside an INTEGER arraylist and lastly print them out ^^"
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Winston Gutkowski wrote:
Lu Kim Hui wrote:Erm... because this is an exercise given from my lecturer, and the requirement is reading from the file and store inside an INTEGER arraylist and lastly print them out ^^"
No. That's the what. You're trying to find out why you're getting an NPE. Have a look at my last question again.
Winston
fred rosenberger wrote:This line:
private ArrayList<Integer> salesList;
says "Eventually, I will create an AraryList that can hold Integers, and I will refer to it by the name salesList".
That's like saying "Someday, i will have a dog and call him 'Rover'". That doesn't mean you HAVE a dog - it just means that someday you will, and you've already picked out the name.
You never create the ArrayList. So, when you further down say "add something into the ArrayList named 'salesList'", the JVM is saying "ummm....WHAT arraylist? There is no such thing!!!"
Lu Kim Hui wrote:THANKS ALOT!!!
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Lu Kim Hui wrote:THANKS ALOT!!!
Another satisfied customer. And isn't it much better when you work it out for yourself?
Winston
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Another tip for you: Get used to reading your stacktraces thoroughly.
Go through them and work out exactly which statements are involved and the order they were invoked. Personally, I use a yellow marker pen; but I'm an old fart and I hate looking at large programs on screens (and I recycle my paper ).
Winston
Campbell Ritchie wrote:Type B paper: this is not all white...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:Paper
There are two sorts of paper when I am around.Type A paper: this is white and is a hazard to life and limb because I try to write on it and nobody can read it. Type B paper: this is not all white, but has writing on already, and is a hazard to life and limb because the chances of my losing it are in proportion to the importance of the writing.
In my opinion, you should instantiate that List inside the constructorYou should also avoid if (...) b = true ; else b = false; Look here for a better example.
Are you closing a Scanner using System.in? You shouldn’t do that. To find out why, add this line after line 20
You’re welcome. Paper should be abolished, except in books and newspapers.Lu Kim Hui wrote: . . .
Thanks for the advice..... i am still a newbie
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |