• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

only 1 of 2 method calls work in the same class

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry
 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Maybe he went home and went to bed. And took this tiny ad with him:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic