As we all known mv command can help me to rename one file. rename is another command to rename file and files. rename command is very useful for renaming multiple files. For example you have three files like following.
Question: Design a stack supports all stack operations and an extra function getMin() which can get the min element of the stack. The time complexity of all operations above must be O(1).
ForkJoinPool is used to handle the big task which can split into small tasks. I will show you how to use ForkJoinPool and RecursiveTask in this page. Let's say you want to calculate the sum from 1 to 1,000,000,000. There are two ways to calculate. The first way: calculate directly. The second way: split 1,000,000,000 numbers into different groups and calculate them in different thread then adding their respective results together. ForkJoinPool can help you to use different threads
I use Intellij IDEA on Linux Mint. Today I found the shortcut Alt + Insert not working. I guess other program may register the same shortcut(Alt + Insert). I close other programs and retry the shortcut again. It's still not working. I know this shortcut may conflict with the system hotkey.
It will throw ConcurrentModificationException when multiple threads modify ArrayList. If the elements are not too much, CopyOnWriteArrayList is a good choice. CopyOnWriteArrayList copies elements when add new element. It is not recommend to using it when the elements are too many. (It is expensive to copy too many elements.)
Using git branch -d to delete local branch. Using git push -u origin --delete to delete the remote branch.
Using following command to checkout new branch and rename it.
Use following SQL to show the database name which you are connecting.
Jackson is a high-performance JSON processor for Java
When I use git push to push local changes to github I got this error message:error: The requested URL returned error: 403 Forbidden while accessing https://github.com/ fatal: HTTP request failed. It is easy to solve this problem.
We can use clone method to clone an object. This is a native method in Object (make it faster). If you want to use this method you need to implement cloneable interface. If you want to use this method in different package do not forget change this method to be public. The example code is here.
In this blog I will show you how to calculate two milliseconds in Java8. Java8 adds a new package java.time. It is easy to handle time by using the class in this package. The example code is here.
Deadlock means multiple workers(threads) are waiting for each other release common resource. In this blog I will create a deadlock example. Two workers both need lock1 and lock2 to finish the task. When one hold lock1 and another hold lock2 they are both waiting for another to release the lock. This state is called dead lock.
retainAll method is used to remove the elements which not in both collections. The example code is here.
Today I solve a problem about missing http header. I add some extra information in http headers when I request server. The code works well in my local environment. When I deploy it on the remote machine some http headers are missing. After google I solve the problem.