• Post Reply Bookmark Topic Watch Topic
  • New Topic

using getter to retrieve an array  RSS feed

 
Mike Osterhout
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to figure out how I can access an array.

I am using the following code in a class called Inventory.


I am then trying to access that data in another class with the following


Everything compiles but it prints NULL in Dos. Any help is greatly appreciated on this topic.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you call setInvName on the new Inventory object? If not, all elements of the array will be null, and you'll get null when you call getInvName.

(With "Dos", I guess you mean the Windows command prompt window? MS-DOS hasn't been on computers for a long time... )
 
Mike Osterhout
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep that does it. My professor really raised the bar on this latest "inventory management" project. Gotta love summer classes!

Thanks for the help, and by DOS I did mean the command line, I figured we could call it that, but i guess not.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!