@@ -0,0 +1,882 @@
+package leetcode._3sum_closest;%0A%0Aimport java.util.Arrays;%0A%0Apublic class Solution %7B%0A%09%0A    public int threeSumClosest(int%5B%5D num, int target) %7B%0A    %09Arrays.sort(num);%0A    %09int length = num.length;%0A    %09int ans = num%5B0%5D + num%5B1%5D + num%5B2%5D;%0A    %09int mindiff = target - ans;%0A    %09for(int i = 0; i %3C length; i++)%7B%0A    %09%09int head = i + 1, tail = length - 1;%0A    %09%09while(head %3C tail)%7B%0A    %09%09%09int sum = num%5Bi%5D + num%5Bhead%5D + num%5Btail%5D;%0A    %09%09%09int diff = target - sum;%0A    %09%09%09if(Math.abs(diff) %3C mindiff)%7B%0A    %09%09%09%09mindiff = Math.abs(diff);%0A    %09%09%09%09ans = sum;%0A    %09%09%09%7D%0A    %09%09%09if(diff %3E 0)%7B%0A    %09%09%09%09head++;%0A    %09%09%09%7Delse if(diff %3C 0)%7B%0A    %09%09%09%09tail--;%0A    %09%09%09%7Delse%7B%0A    %09%09%09%09return target;%0A    %09%09%09%7D%0A    %09%09%7D%0A    %09%7D%0A    %09return ans;%0A    %7D%0A    %0A    public static void main(String%5B%5D args)%7B%0A    %09int%5B%5D input = new int%5B%5D%7B1, 2, 3%7D;%0A    %09System.err.println(new Solution().threeSumClosest(input, 0));%0A    %7D%0A%7D%0A

Add java solution for 16. 3Sum Closest