• Post Reply Bookmark Topic Watch Topic
  • New Topic

two issues with the following code  RSS feed

 
Greenhorn
Posts: 13
Chrome Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help identifing and fixing the two issues with the following code:

 
Saloon Keeper
Posts: 3330
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be more specific with your question. What two problems?

Your variable "availableLanes" has not been initialized so it will be null causing a run-time null pointer exception.
SORRY, my mistake. Ignore this.

[edit] If you have compile or run-time errors cut and paste them in their entirety to a new post.
 
Carey Brown
Saloon Keeper
Posts: 3330
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not checking to see if a lane is available before taking it.
You have no way to relinquish a lane or reset all lanes.

A suggestion: instead of using a Set<Integer> which would only let you know if a lane has not been taken, but leaves you no way to relinquish a lane, you might instead want to use a Map<Integer,Boolean>. A Map like a Set only allows unique keys so that you know that the lane number is unique. A Map would allow you to use the Boolean to indicate whether or not the lane is taken.
 
Jonathan Mckulsky
Greenhorn
Posts: 13
Chrome Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in line 19 it is saying that the Set is abstract? what does that mean?
 
Sheriff
Posts: 22845
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would that be line 19 of some code that we can't see? I can imagine code which causes the compiler to output an error message like that, but line 19 of your posted code isn't that.
 
Carey Brown
Saloon Keeper
Posts: 3330
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I took the code in your 1st post and it compiled and ran just fine.
Are you sure that the code you posted is the same file as the one you're attempting to compile?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!