4
Answers

passing by value

Ask a question
Marco

Marco

16y
2.1k
1
Hello, I have this problem:

void append (Node n) { //here construct the my list }
void remove(Node n) { find and remove n from the list and change the pointers as well }
void myMethod (LinkedList list, Node n) {
    list.remove(n);
}

static main () {
  List <Node> linkedlist = new List <Node> ll;
  for (int i=0; i< 10; i++) ll.append(new Node (i));
  myMethod (ll, new Node (4));
  //here I'd like that linkedList wasn't changed !!!! (but it's changed)
}

Can I do value passage in this case? thanks


Answers (4)
Next Recommended Forum