This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
ExecutorService executor = Executors.newCachedThreadPool(); | |
Task task = new Task(); | |
Future<Integer> result = executor.submit(task); | |
executor.shutdown(); | |
try { | |
Thread.sleep(1000); | |
} catch (InterruptedException e1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LinkedList_deleteIndex { | |
public class LinkedList<E> { | |
private class Node{ | |
public E e; | |
public Node next; | |
public Node(E e, Node next){ | |
this.e = e; | |
this.next = next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
三种可能: | |
1.头部部加node | |
2.中间加node | |
3.结尾加node | |
*/ | |
public class LinkedList_Add { | |
class LinkedList<E> { | |
// 定义node的property和method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LinkedList_deleteNodeByVal { | |
public class LinkedList<E> { | |
private class Node{ | |
public E e; | |
public Node next; | |
public Node(E e, Node next){ | |
this.e = e; | |
this.next = next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class LinkedList_del_Duplicatation { | |
public class ListNode { | |
public int val; | |
public ListNode next; | |
// constructor | |
public ListNode(int val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class LinkedList_AddTwoList { | |
public class LNode { | |
public int val; | |
public LNode next; | |
// constructor | |
public LNode(int val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class LinkedList_Creation { | |
// 链表节点的定义 | |
public static class Node { | |
public int val; | |
public Node next; | |
public Node(int val) { | |
this.value = val; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class LinkedList_isPalindrome { | |
public static class Node { | |
public int val; | |
public Node next; | |
// constructor | |
public Node(int val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class LinkedList_removeLastKthNode { | |
public static class Node { | |
public int val; | |
public Node next; | |
// constructor | |
public Node(int val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class Queue_TwoStack { | |
private static Stack<Object> stack1 = new Stack<>(); | |
private static Stack<Object> stack2 = new Stack<>(); | |
public static void enqueue(Object item) { | |
stack1.push(item); | |
} |
OlderNewer