【作者:孟祥月 部落格:http://blog.csdn.net/mengxiangyue】 在寫程式的時候,我們希望某一個函數接收的參數,有一個範圍的限制,這時候我們就可以考慮使用泛型的上限和下限去解決。我們先看一段代碼,然後再去詳細解釋。 class Point<T>{private T x;private T y;public T getX(){return x;}public void setX(T x){this.x = x;}public
Design pattern samples in Java. Build status: Introduction Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system. Design patterns can speed up the
都知道如果多個字串拼接的話,用StringBuilder.append會比str+=""效率高很多 因為不用建立string對象和數組拷貝, 在jdk1.5中測試了3中方法清空builder package com.jb.efile.model;import java.io.IOException;public class Test {private static long time;public static void main(String[]
https://leetcode.com/problems/partition-list/description/ Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/description/ Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2)
自從實習以後許久沒有做演算法題了,馬上要校招了,重新開始刷題 Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such
參考:http://blog.163.com/shanqing_shuixiu@yeah/blog/static/165319229201192444434865/ Talk is cheap,show me the code! 同一檔案夾下的多個檔案夾打成一個zip包 import java.io.BufferedInputStream;