• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing to the method?  RSS feed

 
Corey Hartman
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to pass "personListToPrint" to main.java and have it come up when switch 3 is used, however it will not work. I am not sure how to go about fixing this. Any ideas??

here is main.java




and here is database.java





and here is printer.java



basically, it's to run a search on what was added to the program by case 1 in the switch statement in main.java
 
Janeice DelVecchio
Bartender
Posts: 1812
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Why is everything static?
2. What, specifically, doesn't work? What happens when you try it?
 
Janeice DelVecchio
Bartender
Posts: 1812
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait. this doesn't compile. Where is personListToPrint 's declaration?
 
Brian Schuetz
Greenhorn
Posts: 25
Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In main you're calling Database.findPerson(searchFor), but you're not doing anything with the returned ArrayList.

Try:

Printer.printPersonList(Database.findPerson(searchFor));

That way you're passing the resulting ArrayList from findPerson to Printer.printPersonList
 
Aki Mohan
Ranch Hand
Posts: 99
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you forgot to assign value to personListToPrint.

ArrayList<Person> personListToPrint = Database.findPerson(searchFor);

Also, findPerson method in Database class is wrong. Look at the elseif condition also the matches.add(p). Probably try correcting it.
Also, printPersonList is already being used in findPerson then i don't see why calling it again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!