• Post Reply Bookmark Topic Watch Topic
  • New Topic

only 1 of 2 method calls work in the same class  RSS feed

 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I have this class customer and I want printVideo method to be able to print the cVList by cVList.print and it doesn't work BUT in the same class but different method (only to test the portion of the code) I inserted a cVList.print and it prints out everything I want it to and the method works. Thats awesome that it works in the returnVideo method but I don't give a diddly because I'm gonna take the cVList.print(); out anyway because thats now how I want it to work. Any Ideas as to what reason the cVList.print(); does not work in printVideo method?

 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's impossible to say without seeing the VideoList.print method.
 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry
 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the printInfo method in Video class that is used in the print method from VideoList class
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From where is the printVideo method being called? I'd say it's called at a time when "first" -whatever that is- is null.
 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The printVideo method is called in the CustomerList class, inside the printMovies method.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That still doesn't help, since we don't know when printMovies is being called. Maybe "first" in that method is null. :-)

I'd advise to sprinkle System.out.println method calls liberally throughout the code so you see the values of all important variables.

One experiment to try would be: does printVideo work if you call it from line 48?

I also suspect that there should be braces around lines 51 to 53.
 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried adding printVideo(); at line 48 and I'm a little confused at the result I got, it ran the cVList.print(); it printed just fine, and then when it ran the printVideo(); It iterates through the same thing 2 times but it seems that it's not accessing the Customer's first and last name or the Customer ID. This is what I got in the console.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So now we're in the position of not being able to help because we haven't seen the Person class, nor have we seen where the Customer objects are created; both of these locations are obviously related to how and/or whether the names are being initialized and the values returned.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!