﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-&lt;h1&gt;编程之道&lt;/h1&gt;-随笔分类-j2se</title><link>http://www.blogjava.net/yuanhuaming/category/2608.html</link><description>无论是批评的，赞扬的，指着的都请EMAIL给我，你的建议将是我前进的动力!   &lt;A href=mailto:yuanhuaming@56.com &gt;联系我&lt;/A&gt;</description><language>zh-cn</language><lastBuildDate>Fri, 02 Mar 2007 03:32:37 GMT</lastBuildDate><pubDate>Fri, 02 Mar 2007 03:32:37 GMT</pubDate><ttl>60</ttl><item><title>Log4j自己配</title><link>http://www.blogjava.net/yuanhuaming/archive/2006/04/12/40570.html</link><dc:creator>疯流成性</dc:creator><author>疯流成性</author><pubDate>Wed, 12 Apr 2006 02:30:00 GMT</pubDate><guid>http://www.blogjava.net/yuanhuaming/archive/2006/04/12/40570.html</guid><wfw:comment>http://www.blogjava.net/yuanhuaming/comments/40570.html</wfw:comment><comments>http://www.blogjava.net/yuanhuaming/archive/2006/04/12/40570.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yuanhuaming/comments/commentRss/40570.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yuanhuaming/services/trackbacks/40570.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">Log4j</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">主要由三大部分：</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 21.25pt; TEXT-INDENT: -21.25pt; mso-list: l0 level1 lfo1; tab-stops: list 21.25pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">1<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">公共类</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">Logger : </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">负责处理日志记录的大部分操作。</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<span style="mso-spacerun: yes">  </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 21.25pt; TEXT-INDENT: -21.25pt; mso-list: l0 level1 lfo1; tab-stops: list 21.25pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">2<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">公共接口</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">Appender : </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">负责控制日志记录的输出部分。它提供了多种输出目标。</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">2.1.1<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">FileAppender<span style="mso-spacerun: yes">        </span></span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出到文本</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">2.1.2<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">ConsoleAppender<span style="mso-spacerun: yes">     </span></span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出到控制台</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: #333333; FONT-FAMILY: 'MS UI Gothic'; mso-fareast-language: ZH-CN; mso-bidi-font-size: 9.0pt; mso-bidi-font-family: Tahoma">2.1.3<span style="FONT: 7pt 'Times New Roman'">      </span></span>
				<span lang="EN-US" style="COLOR: #333333; FONT-FAMILY: 'MS UI Gothic'; mso-fareast-language: ZH-CN; mso-bidi-font-size: 9.0pt; mso-bidi-font-family: Tahoma">SMTPAppender<span style="mso-spacerun: yes">        </span></span>
				<span lang="ZH-CN" style="COLOR: #333333; FONT-FAMILY: 'MS UI Gothic'; mso-fareast-language: ZH-CN; mso-bidi-font-size: 9.0pt; mso-bidi-font-family: Tahoma">输出到邮件</span>
				<span lang="EN-US" style="COLOR: #333333; FONT-FAMILY: 'MS UI Gothic'; mso-fareast-language: ZH-CN; mso-bidi-font-size: 9.0pt; mso-bidi-font-family: Tahoma">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">2.1.4<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">JDBCAppender<span style="mso-spacerun: yes">       </span></span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出到数据库</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 21.25pt; TEXT-INDENT: -21.25pt; mso-list: l0 level1 lfo1; tab-stops: list 21.25pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">布局</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">Layout : </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">负责格式化</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">Appender</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出。有三种布局模式：</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 49.6pt; TEXT-INDENT: -10mm; mso-list: l0 level2 lfo1; tab-stops: list 49.6pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.1<span style="FONT: 7pt 'Times New Roman'">      </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">SimpleLayout : </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">简单格式</span>
				<span style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt">「</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">DEBUG - Here is some DEBUG</span>
				<span style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt">」</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">的日志输出。</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 49.6pt; TEXT-INDENT: -10mm; mso-list: l0 level2 lfo1; tab-stops: list 49.6pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.2<span style="FONT: 7pt 'Times New Roman'">      </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">HTMLLayout : </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">以</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">HTML</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">表格输出。</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 49.6pt; TEXT-INDENT: -10mm; mso-list: l0 level2 lfo1; tab-stops: list 49.6pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.3<span style="FONT: 7pt 'Times New Roman'">      </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">PatternLayout : </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">自定义格式化的日志输出。打印参数如下：</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.3.1<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">%m </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出代码中指定的消息 </span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.3.2<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">%p </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出优先级，即</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">DEBUG</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">，</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">INFO</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">，</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">WARN</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">，</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">ERROR</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">，</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">FATAL <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.3.3<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">%r </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出自应用启动到输出该</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">log</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">信息耗费的毫秒数 </span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.3.4<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">%c </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出所属的类目，通常就是所在类的全名 </span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.3.5<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">%t </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出产生该日志事件的线程名 </span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.3.6<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">%n </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出一个回车换行符，</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">Windows</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">平台为“</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">\r\n”</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">，</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">Unix</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">平台为“</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">\n”<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt 70.9pt; TEXT-INDENT: -10mm; mso-list: l0 level3 lfo1; tab-stops: list 70.9pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">3.3.7<span style="FONT: 7pt 'Times New Roman'">  </span></span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">%d </span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">输出日志时间点的日期或时间，默认格式为</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">ISO8601</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">，也可以在其后指定格式，比如：</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">%d{yyy MMM dd HH:mm:ss,SSS}</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">，输出类似：</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">2002</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">年</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">10</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">月</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">18</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">日</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">22</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">：</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">10</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">：</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">28</span>
				<span lang="ZH-CN" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">，</span>
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN">921<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0mm 0mm 0pt">
				<span lang="EN-US" style="COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN"> <o:p></o:p></span>
		</p>
		<p>
				<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">log4j.properties</span>
				<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: black; FONT-FAMILY: 'MS UI Gothic'; LETTER-SPACING: 0.4pt; mso-fareast-language: ZH-CN; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">的配置如下：</span>
		</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #000000">#### debug是输出级别，分别是debug&lt;info&lt;warn&lt;error&lt;fatal<br />#### R是输出到log</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">cmd是输出到控制台</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">htm输出到HTML<br />log4j.rootCategory</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">debug</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> R</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> cmd</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> htm<br /><br />##控制台输出<br />log4j.appender.cmd</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">org.apache.log4j.ConsoleAppender<br />#布局格式<br />log4j.appender.cmd.layout</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">org.apache.log4j.PatternLayout<br />log4j.appender.cmd.layout.ConversionPattern</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> %-2r </span>
				<span style="FONT-WEIGHT: bold; COLOR: #800000">[</span>
				<span style="COLOR: #800000">%t</span>
				<span style="FONT-WEIGHT: bold; COLOR: #800000">]</span>
				<span style="COLOR: #000000"> %-6p %c - %m%n<br /><br />##控制台输出<br />log4j.appender.htm</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">org.apache.log4j.FileAppender<br />log4j.appender.htm.File</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">example.html<br />log4j.appender.htm.layout</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">org.apache.log4j.HTMLLayout<br /><br />##log格式输出<br />#log4j.appender.R</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">org.apache.log4j.FileAppender<br />#log4j.appender.R</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">org.apache.log4j.DailyRollingFileAppender<br />log4j.appender.R</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">org.apache.log4j.RollingFileAppender<br />log4j.appender.R.File</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">test.log<br />#最大日志大小<br />log4j.appender.R.MaxFileSize</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">100KB   <br />#最大备份数<br />log4j.appender.R.MaxBackupIndex</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">    <br />log4j.appender.R.layout</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">org.apache.log4j.SimpleLayout<br /></span>
		</div>
		<p>代码如下：<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #0000ff">package</span>
				<span style="COLOR: #000000"> com.hmy.Log4JTest;<br /><br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.File;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> org.apache.log4j.Logger;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> org.apache.log4j.PropertyConfigurator;<br /><br /></span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> Log4jTest {<br />    <br />    </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> {<br />        </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> 自动快速地使用缺省Log4j环境。<br />        </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> BasicConfigurator.configure();<br />        </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> 读取使用Java的特性文件编写的配置文件。<br />        </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> PropertyConfigurator.configure ("/WEB-INF/log4j.properties");<br />        </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> 读取XML形式的配置文件。<br />        </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> DOMConfigurator.configure ("/WEB-INF/log4j.xml");</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">        String file </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> String(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">E:/project by eclipse/test/com/hmy/Log4JTest/log4j.properties</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);              </span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (file </span>
				<span style="COLOR: #000000">!=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">) {<br />            PropertyConfigurator.configure(file);<br />        }<br />    }<br />    <br />    </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> Logger logger </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> Logger.getLogger(Log4jTest.</span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000">);<br />    <br />    </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> main(String[] aaa) {<br />          logger.debug(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Here is some DEBUG</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />          logger.info(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Here is some INFO</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />          logger.warn(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Here is some WARN</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />          logger.error(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Here is some ERROR</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />          logger.fatal(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Here is some FATAL</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />    }<br />}<br /></span>
		</div>
		<p>下面是网上找的一个配置文件,择其一二使用就够用了。<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #000000">
						<p>
								<span>log4j.rootLogger=DEBUG,CONSOLE,A1,im <br />log4j.addivity.org.apache=true </span>
						</p>
						<p>
								<span>
								</span> </p>
						<p>
								<span>
										<font color="#0000ff"># 应用于控制台</font>
										<br />
										<br />log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender <br />log4j.appender.Threshold=DEBUG <br />log4j.appender.CONSOLE.Target=System.out <br />log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout <br />log4j.appender.CONSOLE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n <br />#log4j.appender.CONSOLE.layout.ConversionPattern=[start]%d{DATE}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD] n%c[CATEGORY]%n%m[MESSAGE]%n%n <br /><br /><br /><font color="#0000ff">#应用于文件</font><br /><br />log4j.appender.FILE=org.apache.log4j.FileAppender <br />log4j.appender.FILE.File=file.log <br />log4j.appender.FILE.Append=false <br />log4j.appender.FILE.layout=org.apache.log4j.PatternLayout <br />log4j.appender.FILE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n <br /># Use this layout for LogFactor 5 analysis <br /><br /><br /><br /><font color="#0000ff"># 应用于文件回滚</font><br /><br />log4j.appender.ROLLING_FILE=org.apache.log4j.RollingFileAppender <br />log4j.appender.ROLLING_FILE.Threshold=ERROR <br />log4j.appender.ROLLING_FILE.File=rolling.log <br />log4j.appender.ROLLING_FILE.Append=true <br />log4j.appender.ROLLING_FILE.MaxFileSize=10KB <br />log4j.appender.ROLLING_FILE.MaxBackupIndex=1 <br />log4j.appender.ROLLING_FILE.layout=org.apache.log4j.PatternLayout <br />log4j.appender.ROLLING_FILE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n <br /><br /><br /><font color="#0000ff">#应用于socket</font><br />log4j.appender.SOCKET=org.apache.log4j.RollingFileAppender <br />log4j.appender.SOCKET.RemoteHost=localhost <br />log4j.appender.SOCKET.Port=5001 <br />log4j.appender.SOCKET.LocationInfo=true <br /><font color="#0000ff"># Set up for Log Facter 5</font><br />log4j.appender.SOCKET.layout=org.apache.log4j.PatternLayout <br />log4j.appender.SOCET.layout.ConversionPattern=[start]%d{DATE}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD]%n%c[CATEGORY]%n%m[MESSAGE]%n%n <br /><br /><br /># Log Factor 5 Appender <br />log4j.appender.LF5_APPENDER=org.apache.log4j.lf5.LF5Appender <br />log4j.appender.LF5_APPENDER.MaxNumberOfRecords=2000 <br /><br /><br /><br /><font color="#0000ff"># 发送日志给邮件</font><br /><br />log4j.appender.MAIL=org.apache.log4j.net.SMTPAppender <br />log4j.appender.MAIL.Threshold=FATAL <br />log4j.appender.MAIL.BufferSize=10 <br />log4j.appender.MAIL.From=web@www.wuset.com <br />log4j.appender.MAIL.SMTPHost=www.wusetu.com <br />log4j.appender.MAIL.Subject=Log4J Message <br />log4j.appender.MAIL.To=web@www.wusetu.com <br />log4j.appender.MAIL.layout=org.apache.log4j.PatternLayout <br />log4j.appender.MAIL.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n <br /><br /><br /><br /><font color="#0000ff"># 用于数据库</font><br />log4j.appender.DATABASE=org.apache.log4j.jdbc.JDBCAppender <br />log4j.appender.DATABASE.URL=jdbc:mysql://localhost:3306/test <br />log4j.appender.DATABASE.driver=com.mysql.jdbc.Driver <br />log4j.appender.DATABASE.user=root <br />log4j.appender.DATABASE.password= <br />log4j.appender.DATABASE.sql=INSERT INTO LOG4J (Message) VALUES ('[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n') <br />log4j.appender.DATABASE.layout=org.apache.log4j.PatternLayout <br />log4j.appender.DATABASE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n <br /><br /><br />log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender <br />log4j.appender.A1.File=SampleMessages.log4j <br />log4j.appender.A1.DatePattern=yyyyMMdd-HH'.log4j' <br />log4j.appender.A1.layout=org.apache.log4j.xml.XMLLayout <br /><br /><font color="#0000ff">#自定义Appender <br /></font><br />log4j.appender.im = net.cybercorlin.util.logger.appender.IMAppender <br /><br />log4j.appender.im.host = mail.cybercorlin.net <br />log4j.appender.im.username = username <br />log4j.appender.im.password = password <br />log4j.appender.im.recipient = corlin@cybercorlin.net <br /><br />log4j.appender.im.layout=org.apache.log4j.PatternLayout <br />log4j.appender.im.layout.ConversionPattern =[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n </span>
								<span>
								</span>
						</p>
				</span>
		</div>
		<p> </p>
		<p> </p>
<img src ="http://www.blogjava.net/yuanhuaming/aggbug/40570.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yuanhuaming/" target="_blank">疯流成性</a> 2006-04-12 10:30 <a href="http://www.blogjava.net/yuanhuaming/archive/2006/04/12/40570.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SCJP测试题</title><link>http://www.blogjava.net/yuanhuaming/archive/2005/12/30/26085.html</link><dc:creator>疯流成性</dc:creator><author>疯流成性</author><pubDate>Fri, 30 Dec 2005 08:49:00 GMT</pubDate><guid>http://www.blogjava.net/yuanhuaming/archive/2005/12/30/26085.html</guid><wfw:comment>http://www.blogjava.net/yuanhuaming/comments/26085.html</wfw:comment><comments>http://www.blogjava.net/yuanhuaming/archive/2005/12/30/26085.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yuanhuaming/comments/commentRss/26085.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yuanhuaming/services/trackbacks/26085.html</trackback:ping><description><![CDATA[<P>1。编译和运行下面这段代码的结果是什么？ </P><PRE><CODE style="FONT-SIZE: 12px; FONT-FAMILY: Courier New, Courier, monospace">
  Integer i= new Integer("10");
  if (i.toString() == i.toString())
    System.out.println("Equal");
  else
    System.out.println("Not Equal");
</CODE>
</PRE>
<P><B>选项： </B></P>
<UL>
<LI>A. 编译错误 
<LI>B. 输出“Equal” 
<LI>C. 输出“Not Equal” 
<LI>D. 以上都不是 </LI></UL>
<P><B>正确答案： </B></P>
<UL>
<LI>C </LI></UL>
<P><B>说明： </B></P>
<P><CODE><FONT face=Courier size=1>toString()</FONT></CODE> 方法返回等同于这个 <CODE><FONT face=Courier size=1>String</FONT></CODE> 对象的 <CODE><FONT face=Courier size=1>String</FONT></CODE> 。它每次调用时创建一个新的对象。 <CODE><FONT face=Courier size=1>==</FONT></CODE> 操作符比较两个对象引用的位模式而不是实际的 <CODE><FONT face=Courier size=1>String</FONT></CODE> 内容。因此比较返回 <CODE><FONT face=Courier size=1>false</FONT></CODE>，执行 <CODE><FONT face=Courier size=1>else</FONT></CODE> 语句，输出“Not Equal”。 
<HR>

<P></P>
<P>2。在下面代码中，“insert code here”位置可以合法地插入哪个选项？&nbsp;<CODE style="FONT-SIZE: 12px; FONT-FAMILY: Courier New, Courier, monospace"><BR>&nbsp; class Parent<BR>&nbsp; { <BR>&nbsp;&nbsp;&nbsp; public void print(int i) <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; } <BR>&nbsp; public class Child extends Parent<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; public static void main(String argv[]) <BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp; // insert code here<BR>&nbsp; }</CODE><BR></P>
<P><B>选项： </B></P>
<UL>
<LI>A. public void print(int i, byte b) throws Exception {} 
<LI>B. public void print(int i, long i) throws Exception {} 
<LI>C. public void print(long i) {} 
<LI>D. public void print(int i) throws Exception {} 
<LI>E. public int print(int i) </LI></UL>
<P><B>正确答案： </B></P>
<UL>
<LI>A，B 和 C </LI></UL>
<P><B>说明： </B></P>
<P>选项 D 不能编译，因为它试图抛出一个在 <CODE><FONT face=Courier size=1>Parent</FONT></CODE> 类中没有声明的 checked 异常。选项 E 将不能编译，因为只有返回类型不相同，而参数列表和方法名是相同的。这对于覆盖和重载都是不允许的。选项 A、B 和 C 有不同的参数表，所以它们表示 <I>重载 </I>而不是 <I>覆盖 </I>。因为它们可以抛出任何异常，所以它们是合法的。 
<HR>

<P></P>3。编译和运行以下程序会有什么结果？&nbsp;<CODE style="FONT-SIZE: 12px; FONT-FAMILY: Courier New, Courier, monospace"><BR>&nbsp; class Test <BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; public static void main(String args[]) <BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String s1 = "abc";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String s2 = "abc";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s1 += "xyz";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s2.concat("pqr");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s1.toUpperCase();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(s1 + s2);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }</CODE><BR>
<P><B>选项： </B></P>
<UL>
<LI>A. "abcxyzabc" 
<LI>B. "abcxyzabcpqr" 
<LI>C. "ABCXYZabcpqr" 
<LI>D. "ABCXYZabc" 
<LI>E. 代码不能编译 </LI></UL>
<P><B>正确答案： </B></P>
<UL>
<LI>A </LI></UL>
<P><B>说明： </B></P>
<P>这段代码可以无错误地编译运行，输出“abcxyxabc”。在这段代码中， <CODE><FONT face=Courier size=1>s1</FONT></CODE> 和 <CODE><FONT face=Courier size=1>s2</FONT></CODE> 最初指向同一个 <CODE><FONT face=Courier size=1>String</FONT></CODE> 对象“abc”。当“xyz”连接到 <CODE><FONT face=Courier size=1>s1</FONT></CODE> 上时，就创建了一个新的 <CODE><FONT face=Courier size=1>String</FONT></CODE> 对象“abcxyz” ，并且 <CODE><FONT face=Courier size=1>s1</FONT></CODE> 指向它。注意 <CODE><FONT face=Courier size=1>s2</FONT></CODE> 仍然指向原来的 <CODE><FONT face=Courier size=1>String</FONT></CODE> 对象“abc”，它没有改变。 <CODE><FONT face=Courier size=1>concat()</FONT></CODE> 和 <CODE><FONT face=Courier size=1>toUpperCase()</FONT></CODE> 方法没有任何效果，因为作为这些操作的结果创建的新 <CODE><FONT face=Courier size=1>String</FONT></CODE> 对象不拥有任何引用。所以最后 <CODE><FONT face=Courier size=1>s1</FONT></CODE> 包含“abcxyz”而 <CODE><FONT face=Courier size=1>s2</FONT></CODE> 包含“abc”，从而 A 为正确结果。 
<HR>
</P><img src ="http://www.blogjava.net/yuanhuaming/aggbug/26085.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yuanhuaming/" target="_blank">疯流成性</a> 2005-12-30 16:49 <a href="http://www.blogjava.net/yuanhuaming/archive/2005/12/30/26085.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于构造函数</title><link>http://www.blogjava.net/yuanhuaming/archive/2005/12/29/25869.html</link><dc:creator>疯流成性</dc:creator><author>疯流成性</author><pubDate>Thu, 29 Dec 2005 05:45:00 GMT</pubDate><guid>http://www.blogjava.net/yuanhuaming/archive/2005/12/29/25869.html</guid><wfw:comment>http://www.blogjava.net/yuanhuaming/comments/25869.html</wfw:comment><comments>http://www.blogjava.net/yuanhuaming/archive/2005/12/29/25869.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yuanhuaming/comments/commentRss/25869.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yuanhuaming/services/trackbacks/25869.html</trackback:ping><description><![CDATA[<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;构造函数名必须与类名相匹配并且必须没有返回类型。它们可以被重载，但是不被子类继承。 当类被实例化时，就会自动调用构造函数。<BR><BR><STRONG>调用构造函数&nbsp;<BR></STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;只能从其他构造函数中调用构造函数。要调用同一个类中的构造函数，用匹配的参数调用 <CODE><FONT face=Courier size=1>this()</FONT></CODE> 函数。要调用超类中的构造函数，用匹配的参数调用 <CODE><FONT face=Courier size=1>super()</FONT></CODE> 函数。创建子类对象时，按层次结构中从上到下的顺序调用所有超类的构造函数。 </P>
<P><B>默认构造函数&nbsp;</B><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如果没有在类中提供任何其他构造函数，编译器将创建默认构造函数。它没有任何参数。默认构造函数调用超类的无参数构造函数。它与类有同样的访问修饰符。 <BR><BR><STRONG>构造函数的几种用法<BR>1。</STRONG>如果调用类的默认构造函数，而父类有带参数的构造函数，那么您的代码将不能编译。原因是子类的默认构造函数隐式地调用其父类的无参数构造函数。<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">编译错误</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #0000ff">&nbsp;&nbsp;&nbsp;class</SPAN><SPAN style="COLOR: #000000">&nbsp;Temp<BR><IMG id=Codehighlighter1_18_97_Open_Image onclick="this.style.display='none'; Codehighlighter1_18_97_Open_Text.style.display='none'; Codehighlighter1_18_97_Closed_Image.style.display='inline'; Codehighlighter1_18_97_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top></SPAN><SPAN id=Codehighlighter1_18_97_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"></SPAN><SPAN id=Codehighlighter1_18_97_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;x,&nbsp;y;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;Temp(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;x,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;y)&nbsp;<BR><IMG id=Codehighlighter1_56_95_Open_Image onclick="this.style.display='none'; Codehighlighter1_56_95_Open_Text.style.display='none'; Codehighlighter1_56_95_Closed_Image.style.display='inline'; Codehighlighter1_56_95_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top>&nbsp;</SPAN><SPAN id=Codehighlighter1_56_95_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.x&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;x;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.y&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;y;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_124_196_Open_Image onclick="this.style.display='none'; Codehighlighter1_124_196_Open_Text.style.display='none'; Codehighlighter1_124_196_Closed_Image.style.display='inline'; Codehighlighter1_124_196_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;test&nbsp;</SPAN><SPAN style="COLOR: #0000ff">extends</SPAN><SPAN style="COLOR: #000000">&nbsp;Temp&nbsp;</SPAN><SPAN id=Codehighlighter1_124_196_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"></SPAN><SPAN id=Codehighlighter1_124_196_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;main(String&nbsp;args[])<BR><IMG id=Codehighlighter1_168_194_Open_Image onclick="this.style.display='none'; Codehighlighter1_168_194_Open_Text.style.display='none'; Codehighlighter1_168_194_Closed_Image.style.display='inline'; Codehighlighter1_168_194_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_168_194_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"></SPAN><SPAN id=Codehighlighter1_168_194_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test&nbsp;dot</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;test();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV><BR>2。如果构造函数是私有的话，则该对象只能在该类中实例化
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">编译出错：不能被实例化</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;test&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;main(String&nbsp;args[])<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp&nbsp;t&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;temp();<BR>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;temp&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;temp()&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">temp</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}</SPAN></DIV><img src ="http://www.blogjava.net/yuanhuaming/aggbug/25869.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yuanhuaming/" target="_blank">疯流成性</a> 2005-12-29 13:45 <a href="http://www.blogjava.net/yuanhuaming/archive/2005/12/29/25869.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>null和 “”</title><link>http://www.blogjava.net/yuanhuaming/archive/2005/10/21/16333.html</link><dc:creator>疯流成性</dc:creator><author>疯流成性</author><pubDate>Fri, 21 Oct 2005 12:20:00 GMT</pubDate><guid>http://www.blogjava.net/yuanhuaming/archive/2005/10/21/16333.html</guid><wfw:comment>http://www.blogjava.net/yuanhuaming/comments/16333.html</wfw:comment><comments>http://www.blogjava.net/yuanhuaming/archive/2005/10/21/16333.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yuanhuaming/comments/commentRss/16333.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yuanhuaming/services/trackbacks/16333.html</trackback:ping><description><![CDATA[<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;今天碰到一个很奇怪的问题，是从数据库中取某个时间类型字段的值，需要把它转成string型，然后问题就出来了，因为这个字段可能存在空值，断点后走到转string型这行就报错。一直没想明白，后来老大跑过来瞄了几眼就指出了问题所在。高人就是高人啊！<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;由于从数据库读到的空字段＝null的，所以当我toString()的时候肯定会报错。举个例子：<BR><BR>public class test{<BR>&nbsp;public test(){<BR>&nbsp;&nbsp;Object s = null;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//这比作字段的值<BR>&nbsp;&nbsp;String s1 = s.toString();&nbsp;&nbsp;&nbsp;//报错<BR>&nbsp;&nbsp;System.out.println (s1);<BR>&nbsp;}&nbsp;<BR>&nbsp;public static void main(String[] a){<BR>&nbsp;&nbsp;new test();<BR>&nbsp;}<BR>}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;解决的办法就是写一个方法将所有为NULL的值赋为空<BR><BR>public class test{<BR>&nbsp;public test(){<BR>&nbsp;&nbsp;Object s = null;<BR>&nbsp;&nbsp;String s1 = this.strSafe(s);<BR>&nbsp;&nbsp;System.out.println (s1);&nbsp;}<BR>&nbsp;<BR>&nbsp;public static void main(String[] a){<BR>&nbsp;&nbsp;new test();<BR>&nbsp;}&nbsp;<BR>&nbsp;<BR>&nbsp;public String strSafe(Object obj){<BR>&nbsp;&nbsp;if(obj == null)<BR>&nbsp;&nbsp;&nbsp;obj="";<BR>&nbsp;&nbsp;return obj.toString();<BR>&nbsp;}<BR>}<BR><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;最近我感觉越来越迟钝了，想个很简单的for循环就要想老半天。郁闷啊，等发钱了买脑轻松去了<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P><img src ="http://www.blogjava.net/yuanhuaming/aggbug/16333.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yuanhuaming/" target="_blank">疯流成性</a> 2005-10-21 20:20 <a href="http://www.blogjava.net/yuanhuaming/archive/2005/10/21/16333.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>classpath心得</title><link>http://www.blogjava.net/yuanhuaming/archive/2005/08/31/11610.html</link><dc:creator>疯流成性</dc:creator><author>疯流成性</author><pubDate>Wed, 31 Aug 2005 02:55:00 GMT</pubDate><guid>http://www.blogjava.net/yuanhuaming/archive/2005/08/31/11610.html</guid><wfw:comment>http://www.blogjava.net/yuanhuaming/comments/11610.html</wfw:comment><comments>http://www.blogjava.net/yuanhuaming/archive/2005/08/31/11610.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/yuanhuaming/comments/commentRss/11610.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yuanhuaming/services/trackbacks/11610.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classpath问题可以说是所有初学者头疼的问题，我也是过来人，为了兄弟们能少走弯路，我就无私奉献一下我的经验心得。<BR>1) classpath的作用：它的作用就事让java找到你所要执行，或你拥有的类。<BR>2) classpath的设置：设置classpath，一般是在系统环境中设置。<BR>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;一般我们在一个类中声明包名如下：<BR>package com.demo;<BR>public class test{<BR>&nbsp;&nbsp;&nbsp;public static void main(String[] args){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print("this is a test!");<BR>&nbsp;&nbsp;&nbsp;}<BR>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;就是把test类放进com\demo目录下，但这时你不能在com\demo里执行java test,因为JAVA是通过classpath去找test.java的，所以它找的默认目录里的test.java(如果没有就报错)；而不是去找com\demo目录下的test.java。<BR>&nbsp;这是因为java只会在classpath中找有关java的东西，不会理会path。只有这样才能跨平台嘛。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如果你想运行你包里的JAVA类，那就要设置一下环境变量：<BR>a.先确定你的包在哪个盘，比方说在C：的话<BR>b.然后设classpath=C:\;<BR>c.可以有2种访问方式:<BR>&nbsp;&nbsp;&nbsp;1) C:\com\demo&gt;javac test.java<BR>&nbsp;&nbsp; 2) C：\任何目录\&gt;java com.demo.test<BR><BR>基本也就这样了，有什么不对的请跟贴！</P><img src ="http://www.blogjava.net/yuanhuaming/aggbug/11610.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yuanhuaming/" target="_blank">疯流成性</a> 2005-08-31 10:55 <a href="http://www.blogjava.net/yuanhuaming/archive/2005/08/31/11610.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java学习笔记－集合框架</title><link>http://www.blogjava.net/yuanhuaming/archive/2005/08/19/10468.html</link><dc:creator>疯流成性</dc:creator><author>疯流成性</author><pubDate>Thu, 18 Aug 2005 22:55:00 GMT</pubDate><guid>http://www.blogjava.net/yuanhuaming/archive/2005/08/19/10468.html</guid><wfw:comment>http://www.blogjava.net/yuanhuaming/comments/10468.html</wfw:comment><comments>http://www.blogjava.net/yuanhuaming/archive/2005/08/19/10468.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yuanhuaming/comments/commentRss/10468.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yuanhuaming/services/trackbacks/10468.html</trackback:ping><description><![CDATA[<P>集合框架是提供管理对象集合的接口和类，它包含3个组件：</P>
<P><BR>1.接口 ：表示集合的抽象数据类型<BR>&nbsp;&nbsp;&nbsp;a.Collection接口：是构建集合框架的根。<BR>&nbsp;&nbsp;&nbsp;b.Set接口：扩展了Collection接口，它不允许有重复元素。<BR>&nbsp;&nbsp;&nbsp;c.List接口：扩展了Collection接口，一些集合具有顺序，通常被成为列表。<BR>&nbsp;&nbsp;&nbsp;d.Map接口：没有继承Collection接口，具有键和值的对象。不能包含重复键，但可以包含重复值。<BR><BR>2.类 ：用于存储集合的实际数据对象<BR>&nbsp;&nbsp;&nbsp;a.ArrayList ：优点是可以动态添加数据元素，遍历效率比LiskedList快。<BR>&nbsp;&nbsp;&nbsp;b.LinkedList：这是一种链表的数据结构，它和数组的区别在于数组是一段连续的内存空间，而<BR>链表可以是不连续的，这一点就说明了链表对内存空间的合理利用。看下单向链表的结构图：<BR><IMG src="http://photo.blogchina.com/data1/2005-6-22/001/134/277/15460/15460_l.jpg"><BR>头节点先指向第1个节点，然后节点1的指针域又指向下一个节点，最后由于节点3后面没元素了，就为null。<BR>试想一下当对链表进行插入删除的时候只需要将指针域的指向改变一下就可以达到所需效果，而数组插入<BR>删除的时候需要将插入或删除的位置后所有元素后移或前移，很显然在算法上插入删除操作链表要比数组快。<BR>说了这么多数组与链表的区别，下面来看看LinkedList这个类怎么用：<BR></P>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<DIV><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">import&nbsp;java.util.</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;linkedlist<BR><IMG id=Codehighlighter1_45_482_Open_Image onclick="this.style.display='none'; Codehighlighter1_45_482_Open_Text.style.display='none'; Codehighlighter1_45_482_Closed_Image.style.display='inline'; Codehighlighter1_45_482_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_45_482_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_45_482_Closed_Text.style.display='none'; Codehighlighter1_45_482_Open_Image.style.display='inline'; Codehighlighter1_45_482_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_45_482_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_45_482_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;main(String[]&nbsp;args)<BR><IMG id=Codehighlighter1_88_480_Open_Image onclick="this.style.display='none'; Codehighlighter1_88_480_Open_Text.style.display='none'; Codehighlighter1_88_480_Closed_Image.style.display='inline'; Codehighlighter1_88_480_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_88_480_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_88_480_Closed_Text.style.display='none'; Codehighlighter1_88_480_Open_Image.style.display='inline'; Codehighlighter1_88_480_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN id=Codehighlighter1_88_480_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_88_480_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;LinkedList&nbsp;linked</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;LinkedList();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">add&nbsp;element</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;linked.add(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">111</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;linked.add(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">222</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;linked.addFirst(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">111</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">allow&nbsp;repeat</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;linked.addLast(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">555</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(linked);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">insert&nbsp;element</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;linked.add(</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">333</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(linked);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">modify&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;linked.</SPAN><SPAN style="COLOR: #0000ff">set</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">555</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(linked);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">remove</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;linked.remove(</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(linked);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV>
<P>&nbsp;&nbsp;&nbsp;c.HashSet：一看就知道是哈西散列表的集合类，不能有重复元素。例子免了，比较简单的，上段代码我已经<BR>后悔写了，用过java的都知道。<BR>&nbsp;&nbsp;&nbsp;d.TreeSet：将元素储存在树中，适合快速检索大量排序信息。<BR>&nbsp;&nbsp;&nbsp;e.HashMap:HashMap 类没有分类或者排序。它允许一个 null 键和多个 null 值。 <BR>Hashtable 类似于 HashMap，但是不允许 null 键和 null 值。它也比 HashMap 慢，因为它是同步的。 <BR></P>
<P>3.算法 :用于操作集合，并被定义为Collections类中的静态方法，给个例子就很好理解了<BR></P>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<DIV><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">import&nbsp;java.util.</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;linkedlist<BR><IMG id=Codehighlighter1_45_474_Open_Image onclick="this.style.display='none'; Codehighlighter1_45_474_Open_Text.style.display='none'; Codehighlighter1_45_474_Closed_Image.style.display='inline'; Codehighlighter1_45_474_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_45_474_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_45_474_Closed_Text.style.display='none'; Codehighlighter1_45_474_Open_Image.style.display='inline'; Codehighlighter1_45_474_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_45_474_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_45_474_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;main(String[]&nbsp;args)<BR><IMG id=Codehighlighter1_88_472_Open_Image onclick="this.style.display='none'; Codehighlighter1_88_472_Open_Text.style.display='none'; Codehighlighter1_88_472_Closed_Image.style.display='inline'; Codehighlighter1_88_472_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_88_472_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_88_472_Closed_Text.style.display='none'; Codehighlighter1_88_472_Open_Image.style.display='inline'; Codehighlighter1_88_472_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN id=Codehighlighter1_88_472_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_88_472_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;LinkedList&nbsp;linked</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;LinkedList();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">add&nbsp;element</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;linked.add(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">111</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;linked.add(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">222</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;linked.addFirst(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">333</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;linked.addLast(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">555</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(linked);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">来个排序</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;Collections.sort(linked);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(linked);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">如果要反转排的要定义一个Comparator的接口</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;Comparator&nbsp;cmp</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">Collections.reverseOrder();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;Collections.sort(linked,cmp);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(linked);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV>
<P><BR>还有N多方法，自己去试试把。<BR></P>
<P>其实还有很多集合类和接口：<BR>最后总结下结合框架的优点(抄书)：<BR>1.集合框架提供了一组可用的集合接口<BR>2.提供了有效的数据结构和算法，减少了编程量<BR>3.使我们方便的扩展集合<BR>4.设计新API的工作降到最少<BR>5.接口算法的可重用性提高了软件的可重用性<BR><BR></P><img src ="http://www.blogjava.net/yuanhuaming/aggbug/10468.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yuanhuaming/" target="_blank">疯流成性</a> 2005-08-19 06:55 <a href="http://www.blogjava.net/yuanhuaming/archive/2005/08/19/10468.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>