diff --git a/doc/cheatsheet/java_trick.md b/doc/cheatsheet/java_trick.md index 52bfe340..8dcc14a7 100644 --- a/doc/cheatsheet/java_trick.md +++ b/doc/cheatsheet/java_trick.md @@ -17,7 +17,7 @@ - Define max-heap - LC 1046 - ```java + ```java // java PriorityQueue heap = new PriorityQueue<>(Comperator.reverseOrder()); ``` diff --git a/leetcode_java/src/main/java/dev/Test2.java b/leetcode_java/src/main/java/dev/Test2.java index c440a4d0..891a22d0 100644 --- a/leetcode_java/src/main/java/dev/Test2.java +++ b/leetcode_java/src/main/java/dev/Test2.java @@ -1,8 +1,8 @@ package dev; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import LeetCodeJava.DataStructure.TreeNode; + +import java.util.*; public class Test2 { public static void main(String[] args) { @@ -34,6 +34,22 @@ public static void main(String[] args) { System.out.println(new int[]{1,2,3}); List x2 = new ArrayList<>(Arrays.asList(1, 2, 3)); + + + // PriorityQueue for PriorityQueue + PriorityQueue pq = new PriorityQueue<>(); + pq.add(1); + + // LinkedList for Queue + Queue q = new LinkedList<>(); + q.add(1); + + + String str = "abcd"; + + System.out.println(str); + System.out.println(str.indexOf(1)); + } }