`
yiyidog125
  • 浏览: 12683 次
  • 性别: Icon_minigender_1
  • 来自: 广州
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表
<T extends Comparable<? super T>> It means that T must implement Comparable<T itself or one of T's superclasses>
Some scenarios on Windows 1. using a notepad to edit a txt file, at the same time, a java program is using BufferedReader to read it, what it read is the stale content. 2. when a lock is grabbed, trying to read file using bufferedReader will cause I/O exception, "java.io.IOException: The process ...

Random sampling

This is an interview question I got. Given an iterator and a sample size, how can you generate a random List. What I was asked to do is to fill this API public static List<Node> randonSampleIter(Iterator<Node> items, int sampleSize) Luckily, I got a similar question, which is kind of the ...
Lab mate came by and talked about a feature he needs to update several textfield periodically on a panel. He is monitoring some resources and will generate a file for display every second, so his UI only needs to read the one-line file once a second and update the textfields. So we got a chance to us ...
This is an example from the official concurrency tutorial. http://download.oracle.com/javase/tutorial/essential/concurrency/deadlock.html The reason for the deadlock here is that there are two sync methods public synchronized void bow(Friend bower) { System.out.format("%s: %s has bowed ...
[url] http://jeremymanson.blogspot.com/2007/08/atomicity-visibility-and-ordering.html [/url] 另外一篇讲volatile的也值得读 http://jeremymanson.blogspot.com/2007/08/volatile-does-not-mean-atomic.html
有感而发一下看到很多这里的帖子基本的分析都不做 上来就是util包里面现成的类估计对各个基本数据结构的复杂度也不清楚因为不知道内在结构 树更是不会 更有荒唐的要把数据存到数据库查 见到不只一次真是惊为天人。 转个Amazon面试官的帖子,感觉说java的非常贴切 http://sites.google.com/site/steveyegge2/five-essential-phone-screen-questions Bad Sign #1a: Me:   So! What languages are you most familiar/proficient with? Them: (w ...
This problem killed me once. the tricky thing is that only judging parent node greater than left child and less than right child is NOT enough. you need to make sure that the right most leave of your right subtree is also less than current node. A fake example is   10 / 5 \   12 public boolean i ...
Given a histogram {1, 3, 4, 6, 2, 1, 3}, calculate the largest rectangle area. idea: for every index(post), we are certain that this rectangle starts from index, but when does it end? if the index is something that is smaller than previous, then the rectangle ends. e.g. the given sample, when index ...
Java introduced Semaphore since 1.5, let's see how we can use it to maintain an order for thread access. Suppose we have the following code: class Foo { public: A(.....); B(.....); } Foo f; f.A(.....); f.B(.....); f.C(.....); Suppose we have the following code to use class Foo. We do not know how ...
Design an algorithm to find all pairs of integers within an array which sum to a specified value. Solution: say the array is X[], given value is M, the solution I know is to create a map containing pairs <M-X[i], count>, when traversing X[], if we find the key exist, that means there is a pair ...
I'd better write down something before I forget 1. LinkedList is doubly linked, so it takes up more space and cannot hold as many elements as ArrayList. 2. Insertion, ArrayList is faster, in the same level, ArrayList may be two times faster, not that obvious with few elements (<100,000) 3. Deleti ...
Global site tag (gtag.js) - Google Analytics