0

I know this question is answered all over the internet, especially here on StackOverflow, but I think I need a more specific answer for my case.

undirectedEdge temp = edgeList.next;

The line above is getting me this error for some reason. The "next" must be null, or something? Here is the top of my undirectedEdge class:

public class undirectedEdge {
public int Ni;
public int Nj;
public int edgeCost;
public undirectedEdge next;

public undirectedEdge(int i, int j, int cost) {
    Ni = i;
    Nj = j;
    edgeCost = cost;
    next = null;
}

public undirectedEdge getNext() { return next; } . . . }

I hope I supplied enough info. Please let me know if I should include some other code. TIA!

shmob
  • 198
  • 2
  • 17
  • Class names should begin with an uppercase letter. – shmosel Nov 22 '17 at 03:08
  • If that line is throwing the exception, it's because `edgeList` is null. – shmosel Nov 22 '17 at 03:09
  • Yes, I know that. But I don't know how to fix that. – shmob Nov 22 '17 at 03:10
  • What does that mean? You don't know how to set a variable? How to check if a variable is null? – shmosel Nov 22 '17 at 03:12
  • I am having a hard time tracing the issue. That's all. – shmob Nov 22 '17 at 03:13
  • You haven't given us any code that actually produces said exception. Either way, you have to learn to debug your own code. See [here](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) for some tips. – shmosel Nov 22 '17 at 03:15
  • I've had plenty of practice debugging code. I am just having an issue with this particular code. – shmob Nov 22 '17 at 03:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/159538/discussion-between-shmob-and-shmosel). – shmob Nov 22 '17 at 03:22

0 Answers0