锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲ts人妖网站,亚洲春色在线视频,亚洲人成网亚洲欧洲无码久久http://m.tkk7.com/dedian/category/11494.html-- 鍏蟲敞鎼滅儲寮曟搸鐨勫紑鍙?/description>zh-cnWed, 28 Feb 2007 20:29:01 GMTWed, 28 Feb 2007 20:29:01 GMT60Understand Java Map Collectionhttp://m.tkk7.com/dedian/archive/2006/09/23/71422.htmlDedianDedianFri, 22 Sep 2006 18:52:00 GMThttp://m.tkk7.com/dedian/archive/2006/09/23/71422.htmlhttp://m.tkk7.com/dedian/comments/71422.htmlhttp://m.tkk7.com/dedian/archive/2006/09/23/71422.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/71422.htmlhttp://m.tkk7.com/dedian/services/trackbacks/71422.html

Dedian 2006-09-23 02:52 鍙戣〃璇勮
]]>
Reader and InputStreamhttp://m.tkk7.com/dedian/archive/2006/08/29/66359.htmlDedianDedianTue, 29 Aug 2006 01:46:00 GMThttp://m.tkk7.com/dedian/archive/2006/08/29/66359.htmlhttp://m.tkk7.com/dedian/comments/66359.htmlhttp://m.tkk7.com/dedian/archive/2006/08/29/66359.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/66359.htmlhttp://m.tkk7.com/dedian/services/trackbacks/66359.html聽聽聽 The purpose of a reader is to interpret a low-level byte stream (ByteArrayInputStream, StringInputStream, FileInputStream and so on) as a character stream and provid character input to whatever class needs it. And it is very simple to convert an inputstream to a reader:
Reader reader = new InputStreamReader( in ); //in is an instance of class InputStream or derived classes
But the issue is sometimes we need convert a reader to inputstream, think about following scenaros:
1.聽 the original inputstream has been filtered by certian reader, now we need save back filtered content into database by inputstream: we can not use original inputstream but filtered stream which can only get from your reader.
2.聽 Given a class who contains a reader to access a streaming content after complex parsering or downloading, we want to utilize the streaming content in this class while not repeating complex operations for content analysis, so we need employ some wrapper methods to get inputstream from reader.

-- Solution:
1. write own InputStream implementation, such as following:

class MyInputStream extends InputStream
{
private Reader rd;
public MyInputStream(Reader rd)
{
super();
this.rd = rd;
}


// implement the read() method to make this all work
publicint read()
{
int t = rd.read();
// you can do your processing on the inputReader here
// fiddle with the values and return
return t;

}
}
Note: Applications that need to define a subclass of InputStream must always provide a method that returns the next byte of input.
(refer to http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html)

-- anything else? BTW, for parsering xml-based input stream by SAX, I am glad to see that the inputSource constructor can take either InputStream or Reader (refer to http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/InputSource.html)




Dedian 2006-08-29 09:46 鍙戣〃璇勮
]]>
Java Logging mechanismhttp://m.tkk7.com/dedian/archive/2006/06/27/55249.htmlDedianDedianMon, 26 Jun 2006 18:49:00 GMThttp://m.tkk7.com/dedian/archive/2006/06/27/55249.htmlhttp://m.tkk7.com/dedian/comments/55249.htmlhttp://m.tkk7.com/dedian/archive/2006/06/27/55249.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/55249.htmlhttp://m.tkk7.com/dedian/services/trackbacks/55249.html
http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html


Dedian 2006-06-27 02:49 鍙戣〃璇勮
]]>
Generic in the Java Programming Languagehttp://m.tkk7.com/dedian/archive/2006/06/23/54615.htmlDedianDedianFri, 23 Jun 2006 01:39:00 GMThttp://m.tkk7.com/dedian/archive/2006/06/23/54615.htmlhttp://m.tkk7.com/dedian/comments/54615.htmlhttp://m.tkk7.com/dedian/archive/2006/06/23/54615.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/54615.htmlhttp://m.tkk7.com/dedian/services/trackbacks/54615.htmlWhen reading GData source code, you will find that there are lots of generic-style code in it, which is one of several extensions of JDK 1.5. If you are using java 1.5 compiler, it is surely deserved to get some ideas about generic. Be noticed that Java generic looks like C++ Temple, but is quite different.

1. what is the idea of generic?
To simply say, generic is an idea of parameterizing type, including class type and other data types.

2. examples?
-- We are familar with some container types, such as Collection. Here is an example for our former (Java 1.4 or before) typical usage:
Vector myList = new Vector();
myList.add(new Integer(100));
Integer value = (Integer)myList.get(0);

now it is better to write like this for type safety: (Eclipse IDE will display type safety warnings for above code if under java 1.5 compiler option)
聽聽Vector<Integer> myList = new Vector<Integer>();
聽聽myList.add(new Integer(100));
聽聽Integer value = myList.get(0);

-- the reason why write code like this is Class Vector has been defined as a generic:
public Class Vector<E>
{
聽聽聽聽聽聽void add(E x);
聽聽聽聽聽 ......
}

-- when we see some angle brackets(invocations) shown in聽declaration, that is a generic. The invocation is a parameterized type. to use this generic, we need specify an actual type argument. (such as Integer as above)

3. trick in generic

-- we know that the idea of generic makes some data type such as container more flexible or acceptable for inputting entries. But that will be also very tricky. To take container as an example of generic, one of tricks is聽can we copy values from one container to another container? if you want to copy like following style, the answer is no.
List<String> ls = new ArrayList<String>();
List<Object> lo = ls; //compile time error!

-- though we know String is a subtype of Object, and we can assign a value of String to an Object. But we can not assign a List of String to a List of Object as a whole part(like reference to a variable). The reason is we can access inner part of List(I mean element here, if List is as a simple data type such as Object, maybe we can do that), that will make List type unsafe. So, Java 1.5 complier will not let you do that.

-- Look inside two styles of code in above examples(of 2), we might say that the older style looks more flexible, because myList can accept more data types besides Integer, but the new style in 1.5 can only take Integer values. Well, if we need more flexible, we apply wildcards for generic.

4. Wildcards and bounded wildcards

-- if we see something like Collection<?> c, there is a question mark in angle brackets. That is Wildcard, which means type is temporarily unknown but it will be replaced by any type.
-- if we see something like Collection<? extends Number> c, that is bounded wildcard, which means the elements in Collection has a supertype bound. You can not put any other type whose supertype is not Number into this Collection.
-- But, no matter wildcard or bounded wildcard, we can not put a specified type value in it, that is because wildcard means type is unknown, you can not give a value to unknown data type.
-- So, what hell can wildcard be used for ? return back the flexible idea we mentioned before. We need apply wildcard to describe a flexible idea in definition or declaration, not to do real things.
for example, we can define an method like this:
void printCollection(Collection<?> c)
{
聽聽聽聽聽聽for(Object e : c){System.out.println(e);}
}
see? that is flexible. You can call this function for any Collection. You can use elements in Collection<?>, just don't try to put something in it.
-- So the question is, if we wanna that flexibility for our method, and we also need put something in it during the subroutine. How can we do? and then, we need use generic method

5. Generic method
-- that means method declaration can also be parameterized.
-- example:
聽聽聽聽public <T> void addCollection(List<T> objs, T obj)
聽 聽{
聽聽聽聽聽聽聽 objs.add(obj);
聽聽 聽}

6. when to use generic method and when to use wildcard ?
-- if the type parameter is used only once, or it has no relationship to other arguments of method including the return type, then wildcard聽is聽better to use to decribe clearer and more concise meanings.
-- otherwise, generic method should be used.
example:
class Collection
{
聽聽聽聽聽聽public static <T, S extends T> void copy(List<T> dest, List<S> src){...}
}
can be better rewritten as :
class Collection
{
聽聽聽聽聽聽public static <T> void copy(List<T> dest, List<? extends T> src){...}
}

reference: http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf



Dedian 2006-06-23 09:39 鍙戣〃璇勮
]]>
Java Interview Questionshttp://m.tkk7.com/dedian/archive/2006/06/02/49832.htmlDedianDedianThu, 01 Jun 2006 22:14:00 GMThttp://m.tkk7.com/dedian/archive/2006/06/02/49832.htmlhttp://m.tkk7.com/dedian/comments/49832.htmlhttp://m.tkk7.com/dedian/archive/2006/06/02/49832.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/49832.htmlhttp://m.tkk7.com/dedian/services/trackbacks/49832.htmlThese questions are very useful for some Java newbies and guys who wanna prepare some interviews on Java programming positions, which is really cool.

reference:
http://www.allapplabs.com/interview_questions/java_interview_questions.htm
http://www.allapplabs.com/interview_questions/java_interview_questions_2.htm
http://www.allapplabs.com/interview_questions/java_interview_questions_3.htm
http://www.allapplabs.com/interview_questions/java_interview_questions_4.htm
http://www.allapplabs.com/interview_questions/java_interview_questions_5.htm
http://www.allapplabs.com/interview_questions/java_interview_questions_6.htm


Dedian 2006-06-02 06:14 鍙戣〃璇勮
]]>
Java Glossary -- Volatilehttp://m.tkk7.com/dedian/archive/2006/05/25/47936.htmlDedianDedianWed, 24 May 2006 20:45:00 GMThttp://m.tkk7.com/dedian/archive/2006/05/25/47936.htmlhttp://m.tkk7.com/dedian/comments/47936.htmlhttp://m.tkk7.com/dedian/archive/2006/05/25/47936.html#Feedback1http://m.tkk7.com/dedian/comments/commentRss/47936.htmlhttp://m.tkk7.com/dedian/services/trackbacks/47936.html
The volatile keyword is used on variables that may be modified simultaneously by other threads. This warns the compiler to fetch them fresh each time, rather than caching them in registers. This also inhibits certain optimisations that assume no other thread will change the values unexpectedly. Since other threads cannot see local variables, there is never any need to mark local variables volatile.

quote from:

http://mindprod.com/jgloss/volatile.html


Dedian 2006-05-25 04:45 鍙戣〃璇勮
]]>
Java Glossary -- Nested Classhttp://m.tkk7.com/dedian/archive/2006/05/16/46314.htmlDedianDedianTue, 16 May 2006 00:22:00 GMThttp://m.tkk7.com/dedian/archive/2006/05/16/46314.htmlhttp://m.tkk7.com/dedian/comments/46314.htmlhttp://m.tkk7.com/dedian/archive/2006/05/16/46314.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/46314.htmlhttp://m.tkk7.com/dedian/services/trackbacks/46314.html
A class within another class

Example:

class EnclosingClass 
{
...
class ANestedClass
{
...
}
}

Purpose:

Reflect and enforce the relationship between two classes. (esp. in the scenarios that the nested class makes sense only in the context of its enclosing class or when it relies on the enclosing class for its functionthe nested class makes sense only in the context of its enclosing class or when it relies on the enclosing class for its function)

Interesting features:

1. An instance of InnerClass can exist only within an instance of EnclosingClass
2. InnerClass instance has direct access to the instance variables and methods of its enclosing instance.
3. two special kinds of inner classes: local classes and anonymous classes

reference:
http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html


Dedian 2006-05-16 08:22 鍙戣〃璇勮
]]>
Abstract classes vs. interfaceshttp://m.tkk7.com/dedian/archive/2006/04/19/41796.htmlDedianDedianTue, 18 Apr 2006 18:15:00 GMThttp://m.tkk7.com/dedian/archive/2006/04/19/41796.htmlhttp://m.tkk7.com/dedian/comments/41796.htmlhttp://m.tkk7.com/dedian/archive/2006/04/19/41796.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/41796.htmlhttp://m.tkk7.com/dedian/services/trackbacks/41796.html
1. Use Interface if something will change frequently in design
2. If the methods can be determined and implemented, use abstract classes to encapsulate them as methods of base classes and therefore can be inherited by subclasses.
3. If you just want to declare some methods in your design which allows to be devoloped from scratch later into different classes, the interface is best choice.
4. if need provide more common data structure, use abstract classes as base class.
5. if want to add your code to other existing third party class for later potential requirement, interface is good to choose.
6. Interfaces are often used to describe certain functionality of classes, thus one class can get multi-funcationlity from multiple interfaces (multiple inheritance), while an abstract class, try to describe a class's general attributes and functionalities which can be reused or re-implemented by its subclasses.
7. in other word, Abstract class want to say is-a proposition, while Interface want to say -able or can-do proposition.

reference:
http://mindprod.com/jgloss/interfacevsabstract.html
http://www.javaworld.com/javaworld/javaqa/2001-04/03-qa-0420-abstract.html

Dedian 2006-04-19 02:15 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 69视频免费观看l| 婷婷精品国产亚洲AV麻豆不片| 亚洲高清视频免费| 99ee6热久久免费精品6| 老司机亚洲精品影院| 亚洲视频免费在线观看| 亚洲av日韩综合一区在线观看| 国产成人高清亚洲一区91| 免费无码av片在线观看| 久久精品亚洲日本佐佐木明希| 一级做a免费视频观看网站| 国产一区二区三区免费看| 亚洲国产AV一区二区三区四区| 毛片视频免费观看| 亚洲乱码卡一卡二卡三| 免费毛片a在线观看67194| 亚洲免费观看网站| 成人黄软件网18免费下载成人黄18免费视频 | 中文字幕无码免费久久99| 亚洲av无码不卡久久| 3d成人免费动漫在线观看| 亚洲黄色免费网站| 1000部啪啪毛片免费看| 亚洲一区二区三区四区视频 | 亚洲日韩中文字幕无码一区| 黄瓜视频高清在线看免费下载| 亚洲一区中文字幕在线观看| 免费人成视频在线| 日韩欧美亚洲国产精品字幕久久久| 成年女人视频网站免费m| 爱情岛亚洲论坛在线观看 | 国产成人亚洲精品影院| 久久国产一片免费观看| 国产亚洲人成网站在线观看不卡| 美女视频黄a视频全免费网站色窝| 久久亚洲国产精品| 黄色片在线免费观看| 午夜亚洲国产精品福利| 国产亚洲美日韩AV中文字幕无码成人| 三级黄色片免费看| 亚洲日本国产精华液|