Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 954 Bytes

Ex_1_3_24.md

File metadata and controls

41 lines (27 loc) · 954 Bytes
title date draft tags categories
Algorithm4 Java Solution 1.3.24
2019-07-04 05:47:10 +0800
false
JAVA
TECH
archives

1.3.24

Problem:

Write a method removeAfter() that takes a linked-list Node as argument and removes the node following the given one (and does nothing if the argument or the next field in the argument node is null).

Solution:

  public static<Item> void removesAfter(Node<Item> n){
    if(n==null || n.next==null){
      return;
    }
    n.next = n.next.next;
  }

when I saw xiaohei'scode. He writes a generic method which confuses me.

Here is a clearer explanation:

2019-07-20-001

Reference:

java generic methods