﻿<?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>C++博客-我的编程乐园-文章分类-JAVA</title><link>http://www.cppblog.com/deercoder/category/12460.html</link><description>&lt;P&gt;&lt;FONT style="FONT-SIZE: 20px" color=#ff0000&gt;积累，坚持！&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="FONT-SIZE: 20px" color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---------我是一只IT小小鸟&lt;/FONT&gt;&lt;/P&gt;</description><language>zh-cn</language><lastBuildDate>Wed, 05 Oct 2011 20:00:42 GMT</lastBuildDate><pubDate>Wed, 05 Oct 2011 20:00:42 GMT</pubDate><ttl>60</ttl><item><title>Java多维数组详解[转载]</title><link>http://www.cppblog.com/deercoder/articles/103591.html</link><dc:creator>刘畅</dc:creator><author>刘畅</author><pubDate>Sun, 20 Dec 2009 13:53:00 GMT</pubDate><guid>http://www.cppblog.com/deercoder/articles/103591.html</guid><wfw:comment>http://www.cppblog.com/deercoder/comments/103591.html</wfw:comment><comments>http://www.cppblog.com/deercoder/articles/103591.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/deercoder/comments/commentRss/103591.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/deercoder/services/trackbacks/103591.html</trackback:ping><description><![CDATA[<p>java语言中，数组是一种最简单的复合数据类型。数组是有序数据的集合，数组中的每个元素具有相同的数据类型，可以用一个统一的数组名和下标来唯一地确定数组中的元素。数组有一维数组和多维数组。 <br>★ 一维数组 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1． 一维数组的定义 </p>
<p>　　type arrayName[ ]； <br>　　类型(type)可以为Java中任意的数据类型，包括简单类型和复合类型。 <br>　　例如： <br>　　　int intArray[ ]； <br>　　　Date dateArray[]; </p>
<p><br>　　2．一维数组的初始化 </p>
<p>　　◇ 静态初始化 <br>　　　　int intArray[]={1,2,3,4}; <br>　　　　String stringArray[]={"abc", "How", "you"}; </p>
<p>　　◇ 动态初始化 <br>　　　 1）简单类型的数组 <br>　　　　int intArray[]; <br>　　　　intArray = new int[5]; </p>
<p>　　　2）复合类型的数组 <br>　　　　String stringArray[ ]; <br>　　　　String stringArray = new String[3];/*为数组中每个元素开辟引用 <br>　　　　　　　　　　　　　　　　　　　　　 空间(32位) */ <br>　　　　stringArray[0]= new String("How");//为第一个数组元素开辟空间 <br>　　　　stringArray[1]= new String("are");//为第二个数组元素开辟空间 <br>　　　　stringArray[2]= new String("you");// 为第三个数组元素开辟空间 </p>
<p>　　3．一维数组元素的引用 </p>
<p>　　数组元素的引用方式为： <br>　　　　　arrayName[index] </p>
<p>　　index为数组下标，它可以为整型常数或表达式，下标从0开始。每个数组都有一个属性length指明它的长度，例如：intArray.length指明数组intArray的长度。 </p>
<p>★多维数组 </p>
<p>　　Java语言中，多维数组被看作数组的数组。 </p>
<p>　　1．二维数组的定义 </p>
<p>　　type arrayName[ ][ ]； <br>　　type [ ][ ]arrayName; </p>
<p>　　2．二维数组的初始化 </p>
<p>　　◇ 静态初始化 <br>　　int intArray[ ][ ]={{1,2},{2,3},{3,4,5}}; </p>
<p>　　Java语言中，由于把二维数组看作是数组的数组，数组空间不是连续分配的，所以不要求二维数组每一维的大小相同。 </p>
<p>　　◇ 动态初始化 <br>　　1) 直接为每一维分配空间，格式如下： <br>　　arrayName = new type[arrayLength1][arrayLength2]; <br>　　int a[ ][ ] = new int[2][3]； </p>
<p>　　2) 从最高维开始，分别为每一维分配空间： <br>　　arrayName = new type[arrayLength1][ ]; <br>　　arrayName[0] = new type[arrayLength20]; <br>　　arrayName[1] = new type[arrayLength21]; <br>　　&#8230; <br>　　arrayName[arrayLength1-1] = new type[arrayLength2n]; </p>
<p>　　3) 例： <br>　　二维简单数据类型数组的动态初始化如下, <br>　　int a[ ][ ] = new int[2][ ]； <br>　　a[0] = new int[3]; <br>　　a[1] = new int[5]; </p>
<p>　　对二维复合数据类型的数组，必须首先为最高维分配引用空间，然后再顺次为低维分配空间。 <br>　　而且，必须为每个数组元素单独分配空间。 </p>
<p>　　例如： <br>　　String s[ ][ ] = new String[2][ ]; <br>　　s[0]= new String[2];//为最高维分配引用空间 <br>　　s[1]= new String[2]; //为最高维分配引用空间 <br>　　s[0][0]= new String("Good");// 为每个数组元素单独分配空间 <br>　　s[0][1]= new String("Luck");// 为每个数组元素单独分配空间 <br>　　s[1][0]= new String("to");// 为每个数组元素单独分配空间 <br>　　s[1][1]= new String("You");// 为每个数组元素单独分配空间 </p>
<p>　　3．二维数组元素的引用 <br>　　 <br>　　对二维数组中的每个元素，引用方式为：arrayName[index1][index2] <br>　　例如： num[1][0];&nbsp;<br>&nbsp;&nbsp;&nbsp;4．二维数组举例： </p>
<p>　　【例2．2】两个矩阵相乘 <br>　　public class MatrixMultiply{ <br>　　　public static void main(String args[]){ <br>　　　int i,j,k; <br>　　　int a[][]=new int [2][3]; //动态初始化一个二维数组 <br>　　　int b[][]={{1,5,2,8},{5,9,10,-3},{2,7,-5,-18}};//静态初始化 <br>　　　　　　　　　　　　　　　　　　　　　　　　　　 一个二维数组 <br>　　　int c[][]=new int[2][4]; //动态初始化一个二维数组 <br>　　　for (i=0;i&lt;2;i++) <br>　　　　　for (j=0; j&lt;3 ;j++) <br>　　　　　　a[i][j]=(i+1)*(j+2); <br>　　　for (i=0;i&lt;2;i++){ <br>　　　　　for (j=0;j&lt;4;j++){ <br>　　　　　　c[i][j]=0; <br>　　　for(k=0;k&lt;3;k++) <br>　　　　　c[i][j]+=a[i][k]*b[k][j]; <br>　　　　　　} <br>　　　　　} <br>　　　System.out.println("*******Matrix C********");//打印Matrix C标记 <br>　　　for(i=0;i&lt;2;i++){ <br>　　　　　for (j=0;j&lt;4;j++) <br>　　　　　　System.out.println(c[i][j]+" "); <br>　　　　　System.out.println(); <br>　　　　　　} <br>　　　　　} <br>　　　} </p>
<p>　　2．5 字符串的处理 </p>
<p>★ 字符串的表示 </p>
<p>　　Java语言中，把字符串作为对象来处理，类String和StringBuffer都可以用来表示一个字符串。(类名都是大写字母打头) </p>
<p>　　1．字符串常量 </p>
<p>　　字符串常量是用双引号括住的一串字符。 <br>　　　　"Hello World!" </p>
<p>　　2．String表示字符串常量 </p>
<p>　　用String表示字符串： <br>　　String( char chars[ ] ); <br>　　String( char chars[ ], int startIndex, int numChars ); <br>　　String( byte ascii[ ], int hiByte ); <br>　　String( byte ascii[ ], int hiByte, int startIndex, int numChars ); <br>　　String使用示例： <br>　　String s=new String() ; 生成一个空串 </p>
<p>　　下面用不同方法生成字符串"abc"： <br>　　char chars1[]={''a'',''b'',''c''}; <br>　　char chars2[]={''a'',''b'',''c'',''d'',''e''}; <br>　　String s1=new String(chars1); <br>　　String s2=new String(chars2,0,3); <br>　　byte ascii1[]={97,98,99}; <br>　　byte ascii2[]={97,98,99,100,101}; <br>　　String s3=new String(ascii1,0); <br>　　String s4=new String(ascii2,0,0,3); <br>3．用StringBuffer表示字符串 </p>
<p>　　StringBuffer( ); /*分配16个字符的缓冲区*/ <br>　　StringBuffer( int len ); /*分配len个字符的缓冲区*/ <br>　　StringBuffer( String s ); /*除了按照s的大小分配空间外,再分配16个 <br>　　　　　　　　　　　　　　　字符的缓冲区*/ </p>
<p>★访问字符串 </p>
<p>　　 1．类String中提供了length( )、charAt( )、indexOf( )、lastIndexOf( )、getChars( )、getBytes( )、toCharArray( )等方法。 </p>
<p>　　◇ public int length() 此方法返回字符串的字符个数 <br>　　◇ public char charAt(int index) 此方法返回字符串中index位置上的字符，其中index 值的 范围是0~length-1 <br>　　◇ public int indexOf(int ch) <br>　　 　public lastIndexOf(in ch) <br>　　 <br>　　返回字符ch在字符串中出现的第一个和最后一个的位置 <br>　　◇ public int indexOf(String str) <br>　　　 public int lastIndexOf(String str) <br>　　返回子串str中第一个字符在字符串中出现的第一个和最后一个的位置 <br>　　◇ public int indexOf(int ch,int fromIndex) <br>　　　 public lastIndexOf(in ch ,int fromIndex) <br>　　返回字符ch在字符串中位置fromIndex以后出现的第一个和最后一个的位置 <br>　　◇ public int indexOf(String str,int fromIndex) <br>　　　 public int lastIndexOf(String str,int fromIndex) <br>　　返回子串str中的第一个字符在字符串中位置fromIndex后出现的第一个和最后一个的位置。 <br>　　◇ public void getchars(int srcbegin,int end ,char buf[],int dstbegin) <br>　　 srcbegin 为要提取的第一个字符在源串中的位置， end为要提取的最后一个字符在源串中的位置，字符数组buf[]存放目的字符串，　　　 dstbegin 为提取的字符串在目的串中的起始位置。 <br>　　◇public void getBytes(int srcBegin, int srcEnd,byte[] dst, int dstBegin) <br>　　参数及用法同上，只是串中的字符均用8位表示。 </p>
<p>　　2．类StringBuffer提供了 length( )、charAt( )、getChars( )、capacity()等方法。 </p>
<p>　　方法capacity()用来得到字符串缓冲区的容量，它与方法length()所返回的值通常是不同的。 <br>&nbsp;<br>★修改字符串 <br>修改字符串的目的是为了得到新的字符串，类String和类StringBuffer都提供了相应的方法。有关各个方法的使用，参考java 2 API。 </p>
<p>　　1．String类提供的方法： </p>
<p>　　　concat( ) <br>　　　replace( ) <br>　　　substring( ) <br>　　　toLowerCase( ) <br>　　　toUpperCase( ) </p>
<p>　　◇ public String contat(String str); <br>　　用来将当前字符串对象与给定字符串str连接起来。 <br>　　◇ public String replace(char oldChar,char newChar); <br>　　用来把串中出现的所有特定字符替换成指定字符以生成新串。 <br>　　◇ public String substring(int beginIndex)； <br>　　public String substring(int beginIndex,int endIndex); <br>　　用来得到字符串中指定范围内的子串。 <br>　　◇ public String toLowerCase(); <br>　　把串中所有的字符变成小写。 <br>　　◇ public String toUpperCase(); <br>　　把串中所有的字符变成大写。 </p>
<p>　　2．StringBuffer类提供的方法： </p>
<p>　　append( ) <br>　　insert( ) <br>　　setCharAt( ) </p>
<p>　　如果操作后的字符超出已分配的缓冲区,则系统会自动为它分配额外的空间。 <br>　　◇ public synchronized StringBuffer append(String str); <br>　　用来在已有字符串末尾添加一个字符串str。 <br>　　◇ public synchronized StringBuffer insert(int offset, String str); <br>　　用来在字符串的索引offset位置处插入字符串str。 <br>　　◇ public synchronized void setCharAt(int index,char ch); <br>　　用来设置指定索引index位置的字符值。 </p>
<p>　　注意：String中对字符串的操作不是对源操作串对象本身进行的，而是对新生成的一个源操作串对象的拷贝进行的，其操作的结果不影响源串。 </p>
<p>　　相反，StringBuffer中对字符串的连接操作是对源串本身进行的，操作之后源串的值发生了变化，变成连接后的串。 </p>
<p>★ 其它操作 </p>
<p>　　 1．字符串的比较 </p>
<p>　　String中提供的方法： <br>　　equals( )和equalsIgnoreCase( ) <br>　　它们与运算符''= =''实现的比较是不同的。运算符''= =''比较两个对象是否引用同一个实例，而equals( )和equalsIgnoreCase( )则比较　　两个字符串中对应的每个字符值是否相同。 </p>
<p>　　2．字符串的转化 </p>
<p>　　java.lang.Object中提供了方法toString( )把对象转化为字符串。 </p>
<p>　　3．字符串"+"操作 </p>
<p>　　运算符''+''可用来实现字符串的连接： <br>　　String s = "He is "+age+" years old."; <br>　　其他类型的数据与字符串进行"+"运算时，将自动转换成字符串。具体过程如下： <br>　　String s=new StringBuffer("he is").append(age).append("years old").toString(); </p>
<p>　　注意：除了对运算符"+"进行了重载外，java不支持其它运算符的重载。&nbsp;&nbsp;&nbsp; </p>
<p>文章出处：DIY部落(<a href="http://www.diybl.com/course/3_program/java/javajs/200847/108479_2.html">http://www.diybl.com/course/3_program/java/javajs/200847/108479_2.html</a>)</p>
<p>文章出处：DIY部落(<a href="http://www.diybl.com/course/3_program/java/javajs/200847/108479.html">http://www.diybl.com/course/3_program/java/javajs/200847/108479.html</a>)</p>
<img src ="http://www.cppblog.com/deercoder/aggbug/103591.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/deercoder/" target="_blank">刘畅</a> 2009-12-20 21:53 <a href="http://www.cppblog.com/deercoder/articles/103591.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>发Java手写代码。</title><link>http://www.cppblog.com/deercoder/articles/103585.html</link><dc:creator>刘畅</dc:creator><author>刘畅</author><pubDate>Sun, 20 Dec 2009 13:16:00 GMT</pubDate><guid>http://www.cppblog.com/deercoder/articles/103585.html</guid><wfw:comment>http://www.cppblog.com/deercoder/comments/103585.html</wfw:comment><comments>http://www.cppblog.com/deercoder/articles/103585.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/deercoder/comments/commentRss/103585.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/deercoder/services/trackbacks/103585.html</trackback:ping><description><![CDATA[<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: #008080">&nbsp;1</span><img id=Codehighlighter1_22_240_Open_Image onclick="this.style.display='none'; Codehighlighter1_22_240_Open_Text.style.display='none'; Codehighlighter1_22_240_Closed_Image.style.display='inline'; Codehighlighter1_22_240_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_22_240_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_22_240_Closed_Text.style.display='none'; Codehighlighter1_22_240_Open_Image.style.display='inline'; Codehighlighter1_22_240_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;ArrayDemo</span><span id=Codehighlighter1_22_240_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_22_240_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img id=Codehighlighter1_63_238_Open_Image onclick="this.style.display='none'; Codehighlighter1_63_238_Open_Text.style.display='none'; Codehighlighter1_63_238_Closed_Image.style.display='inline'; Codehighlighter1_63_238_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_63_238_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_63_238_Closed_Text.style.display='none'; Codehighlighter1_63_238_Open_Image.style.display='inline'; Codehighlighter1_63_238_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.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)</span><span id=Codehighlighter1_63_238_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_63_238_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">[]&nbsp;anArray;&nbsp;anArray&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img id=Codehighlighter1_147_211_Open_Image onclick="this.style.display='none'; Codehighlighter1_147_211_Open_Text.style.display='none'; Codehighlighter1_147_211_Closed_Image.style.display='inline'; Codehighlighter1_147_211_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_147_211_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_147_211_Closed_Text.style.display='none'; Codehighlighter1_147_211_Open_Image.style.display='inline'; Codehighlighter1_147_211_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;&nbsp;i&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">&nbsp;anArray.length;&nbsp;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)</span><span id=Codehighlighter1_147_211_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_147_211_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anArray[i]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;i;<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(anArray[i]&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println();<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<br>
<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: #008080">&nbsp;1</span><img id=Codehighlighter1_33_232_Open_Image onclick="this.style.display='none'; Codehighlighter1_33_232_Open_Text.style.display='none'; Codehighlighter1_33_232_Closed_Image.style.display='inline'; Codehighlighter1_33_232_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_33_232_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_33_232_Closed_Text.style.display='none'; Codehighlighter1_33_232_Open_Image.style.display='inline'; Codehighlighter1_33_232_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;ArrayOfIntergersDemo</span><span id=Codehighlighter1_33_232_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_33_232_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img id=Codehighlighter1_74_230_Open_Image onclick="this.style.display='none'; Codehighlighter1_74_230_Open_Text.style.display='none'; Codehighlighter1_74_230_Closed_Image.style.display='inline'; Codehighlighter1_74_230_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_74_230_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_74_230_Closed_Text.style.display='none'; Codehighlighter1_74_230_Open_Image.style.display='inline'; Codehighlighter1_74_230_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.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)</span><span id=Codehighlighter1_74_230_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_74_230_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Integer[]&nbsp;anArray&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;Integer[</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img id=Codehighlighter1_156_227_Open_Image onclick="this.style.display='none'; Codehighlighter1_156_227_Open_Text.style.display='none'; Codehighlighter1_156_227_Closed_Image.style.display='inline'; Codehighlighter1_156_227_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_156_227_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_156_227_Closed_Text.style.display='none'; Codehighlighter1_156_227_Open_Image.style.display='inline'; Codehighlighter1_156_227_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;&nbsp;i&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">&nbsp;anArray.length;&nbsp;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)</span><span id=Codehighlighter1_156_227_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_156_227_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anArray[i]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;Integer(i);<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(anArray[i]);<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<br>
<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: #008080">&nbsp;1</span><img id=Codehighlighter1_30_251_Open_Image onclick="this.style.display='none'; Codehighlighter1_30_251_Open_Text.style.display='none'; Codehighlighter1_30_251_Closed_Image.style.display='inline'; Codehighlighter1_30_251_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_30_251_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_30_251_Closed_Text.style.display='none'; Codehighlighter1_30_251_Open_Image.style.display='inline'; Codehighlighter1_30_251_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;ArrayOfStringDemo</span><span id=Codehighlighter1_30_251_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_30_251_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img id=Codehighlighter1_71_249_Open_Image onclick="this.style.display='none'; Codehighlighter1_71_249_Open_Text.style.display='none'; Codehighlighter1_71_249_Closed_Image.style.display='inline'; Codehighlighter1_71_249_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_71_249_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_71_249_Closed_Text.style.display='none'; Codehighlighter1_71_249_Open_Image.style.display='inline'; Codehighlighter1_71_249_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.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)</span><span id=Codehighlighter1_71_249_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_71_249_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img id=Codehighlighter1_94_148_Open_Image onclick="this.style.display='none'; Codehighlighter1_94_148_Open_Text.style.display='none'; Codehighlighter1_94_148_Closed_Image.style.display='inline'; Codehighlighter1_94_148_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_94_148_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_94_148_Closed_Text.style.display='none'; Codehighlighter1_94_148_Open_Image.style.display='inline'; Codehighlighter1_94_148_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String[]&nbsp;anArray&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span id=Codehighlighter1_94_148_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_94_148_Open_Text><span style="COLOR: #000000">{&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">String&nbsp;One</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">String&nbsp;Two</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">String&nbsp;Threee</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img id=Codehighlighter1_193_246_Open_Image onclick="this.style.display='none'; Codehighlighter1_193_246_Open_Text.style.display='none'; Codehighlighter1_193_246_Closed_Image.style.display='inline'; Codehighlighter1_193_246_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_193_246_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_193_246_Closed_Text.style.display='none'; Codehighlighter1_193_246_Open_Image.style.display='inline'; Codehighlighter1_193_246_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;&nbsp;i&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">&nbsp;anArray.length;&nbsp;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)</span><span id=Codehighlighter1_193_246_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_193_246_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(anArray[i].toLowerCase());<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<br>
<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: #008080">&nbsp;1</span><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;java.lang.Math;<br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img id=Codehighlighter1_40_417_Open_Image onclick="this.style.display='none'; Codehighlighter1_40_417_Open_Text.style.display='none'; Codehighlighter1_40_417_Closed_Image.style.display='inline'; Codehighlighter1_40_417_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_40_417_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_40_417_Closed_Text.style.display='none'; Codehighlighter1_40_417_Open_Image.style.display='inline'; Codehighlighter1_40_417_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.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;exp</span><span id=Codehighlighter1_40_417_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_40_417_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img id=Codehighlighter1_81_415_Open_Image onclick="this.style.display='none'; Codehighlighter1_81_415_Open_Text.style.display='none'; Codehighlighter1_81_415_Closed_Image.style.display='inline'; Codehighlighter1_81_415_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_81_415_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_81_415_Closed_Text.style.display='none'; Codehighlighter1_81_415_Open_Image.style.display='inline'; Codehighlighter1_81_415_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.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)</span><span id=Codehighlighter1_81_415_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_81_415_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">double</span><span style="COLOR: #000000">&nbsp;x&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">11.635</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">double</span><span style="COLOR: #000000">&nbsp;y&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">2.76</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the&nbsp;value&nbsp;of&nbsp;e&nbsp;is&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;Math.E);<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">exp(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;x&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)&nbsp;is&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;Math.exp(x));<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">log(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">x</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)&nbsp;is&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;Math.log(x));<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pow(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">x</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">y</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)&nbsp;is</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;Math.pow(x,y));<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">sqrt(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">x</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)&nbsp;is&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;Math.sqrt(x));<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<br>
<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: #008080">&nbsp;1</span><img id=Codehighlighter1_17_581_Open_Image onclick="this.style.display='none'; Codehighlighter1_17_581_Open_Text.style.display='none'; Codehighlighter1_17_581_Closed_Image.style.display='inline'; Codehighlighter1_17_581_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_17_581_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_17_581_Closed_Text.style.display='none'; Codehighlighter1_17_581_Open_Image.style.display='inline'; Codehighlighter1_17_581_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;Trig</span><span id=Codehighlighter1_17_581_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_17_581_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img id=Codehighlighter1_58_579_Open_Image onclick="this.style.display='none'; Codehighlighter1_58_579_Open_Text.style.display='none'; Codehighlighter1_58_579_Closed_Image.style.display='inline'; Codehighlighter1_58_579_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_58_579_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_58_579_Closed_Text.style.display='none'; Codehighlighter1_58_579_Open_Image.style.display='inline'; Codehighlighter1_58_579_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.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)</span><span id=Codehighlighter1_58_579_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.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_58_579_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">double</span><span style="COLOR: #000000">&nbsp;degree&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">45.0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">double</span><span style="COLOR: #000000">&nbsp;redians&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;Math.toDegrees(degree);<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the&nbsp;value&nbsp;of&nbsp;pi&nbsp;is</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;Math.PI);<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the&nbsp;sin&nbsp;of</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;degree&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;is&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">Math.sin(degree));<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the&nbsp;cos&nbsp;of&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;degree&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;is&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">Math.cos(degree));<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the&nbsp;tan&nbsp;of&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;degree&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;is&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">Math.tan(degree));<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the&nbsp;arc&nbsp;tan&nbsp;of&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;redians&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;is&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">Math.atan(redians));<br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the&nbsp;arc&nbsp;sin&nbsp;of&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;redians&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;is&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">Math.asin(redians));<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<br><br>发点思考：<br>1，按照书上面一个个敲代码是很有好处的。手写代码也是不错的。原始的方法或许更加有效果！<br>2.java的几点，从这个上面看来。1，java中，一个数组，可以是对象数组，就是说它的内容是一个对象，这样的，它的创建不仅要new，其中的内容也要new，否则没有创建对象哪里来的那些内容呢？<br>就像是内置类型一样，那些new处理的当然也是数组，所以是Integer[5]来表示数组。<br>而要是赋值或者初始化的话，就是用的括号，表示调用构造函数，因为类和构造函数是同名的。这次就完成了上面的内容。。
<img src ="http://www.cppblog.com/deercoder/aggbug/103585.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/deercoder/" target="_blank">刘畅</a> 2009-12-20 21:16 <a href="http://www.cppblog.com/deercoder/articles/103585.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java中一个很简单的输出显示</title><link>http://www.cppblog.com/deercoder/articles/103579.html</link><dc:creator>刘畅</dc:creator><author>刘畅</author><pubDate>Sun, 20 Dec 2009 12:32:00 GMT</pubDate><guid>http://www.cppblog.com/deercoder/articles/103579.html</guid><wfw:comment>http://www.cppblog.com/deercoder/comments/103579.html</wfw:comment><comments>http://www.cppblog.com/deercoder/articles/103579.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/deercoder/comments/commentRss/103579.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/deercoder/services/trackbacks/103579.html</trackback:ping><description><![CDATA[<p>敲代码有时候还是有好处的，看看下面的这个代码，我才发现直接OUT了。<br>exp.java<br><br>import java.lang.Math;</p>
<p>public class exp{<br>&nbsp;public static void main(String[] args){<br>&nbsp;&nbsp;double x = 11.635;<br>&nbsp;&nbsp;double y = 2.76;<br>&nbsp;&nbsp;System.out.println("the value of e is " + Math.E);<br>&nbsp;&nbsp;System.out.println("exp(" + x + ") is " + Math.exp(x));<br>&nbsp;&nbsp;System.out.println("log(" +x+ ") is " + Math.log(x));</p>
<p>&nbsp;&nbsp;System.out.println("pow(" +x+ "," +y+ ") is" + Math.pow(x,y));<br>&nbsp;&nbsp;System.out.println("sqrt(" +x+ ") is " + Math.sqrt(x));<br>&nbsp;}<br>}</p>
<br>实例代码如下所示："exp(" + x + ") is "<br>&nbsp;此部分如何解释呢？是因为那些函数的特殊显示效果吗？特定的格式吗？<br>其实，Java和C++一样，都是字符串链接形式的输出。所以应该是：<br>每两个引号连接成一对，然后输出，而没有连接的，就是要直接输出的，比如变量，比如字符串对象&#8230;&#8230;&#8230;&#8230;<br>所以显示的先是：exp（ ，然后显示x，这中间用一个+连接两个字符串，然后连接上剩下的另外一部分字符串，就是) is部分。所以最终显示就是exp(11.635)，就这样形成了输出的格式。所以就出现了。<br><br>分析问题，冷静思考才是王道！<br>有时候发现，很多东西都是相同的，不管是C++还是Java！<br>
<img src ="http://www.cppblog.com/deercoder/aggbug/103579.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/deercoder/" target="_blank">刘畅</a> 2009-12-20 20:32 <a href="http://www.cppblog.com/deercoder/articles/103579.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转载】NetBeans生成Applet的实例方法</title><link>http://www.cppblog.com/deercoder/articles/103176.html</link><dc:creator>刘畅</dc:creator><author>刘畅</author><pubDate>Mon, 14 Dec 2009 05:13:00 GMT</pubDate><guid>http://www.cppblog.com/deercoder/articles/103176.html</guid><wfw:comment>http://www.cppblog.com/deercoder/comments/103176.html</wfw:comment><comments>http://www.cppblog.com/deercoder/articles/103176.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/deercoder/comments/commentRss/103176.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/deercoder/services/trackbacks/103176.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp; JCreator可谓是个实在轻量级的IDE了，但是就向我昨天写的那篇，用它写applet非常容易，目录层次没有使用其他开发工具那么复杂（相比而言）。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Java Studio 和 NetBeans IDE如出一辙，原本 Java Studio 也是在 NetBeans 的基础上开发的，所以，卸了Studio，开始深入学习 NetBeans。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 下面介绍如何使用 NetBeans 写 Applet。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 一、创建或导入applet文件：</p>
<p>&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 选择&#8220;文件&#8221;</p>
<p>&lt;font size="3"&gt;&amp;gt;&lt;/font&gt;&#8220;新建项目&#8221;(Ctrl-Shift-N)。在&#8220;类别&#8221;下选择&#8220;常规&#8221;。</p>
<p><br />&nbsp;&nbsp;&nbsp; 2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 选择以下选项之一：<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果要创建新的 Applet 源文件，请在&#8220;项目&#8221;下选择&#8220;Java 类库&#8221;。单击&#8220;下一步&#8221;。<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果要导入 Applet 源文件，请选择&#8220;包含现有源的 Java 项目&#8221;。单击&#8220;下一步&#8221;。在&#8220;源包文件夹&#8221;文本框中指定文件的位置 。</p>
<p><br />&nbsp;&nbsp;&nbsp; 3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在&#8220;项目名称&#8221;下键入 HelloApplet。将&#8220;项目位置&#8221;更改为计算机中的项目存储位置。</p>
<p>&nbsp;&nbsp;&nbsp; 4.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 单击&#8220;完成&#8221;。如果导入了 Applet 源文件，直接参考下面部分的运行和调试。</p>
<p>&nbsp;&nbsp;&nbsp; 二、创建applet源文件：</p>
<p>&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在&#8220;项目&#8221;窗口中，右键单击 HelloApplet 项目节点，然后选择&#8220;新建文件/文件夹&#8221;(Ctrl-N)。</p>
<p>&nbsp;&nbsp;&nbsp; 2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在&#8220;类别&#8221;下选择&#8220;Java 类&#8221;。在&#8220;文件类型&#8221;下选择 \"Applet\"。单击&#8220;下一步&#8221;。</p>
<p>&nbsp;&nbsp;&nbsp; 3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在&#8220;类名&#8221;下键入 myApplet。在&#8220;包&#8221;下键入 ncut.zyf.hello。</p>
<p>&nbsp;&nbsp;&nbsp; 4.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 单击&#8220;完成&#8221;。IDE 会在指定的包中创建 Applet 源文件。将在源编辑器中打开 Applet 源文件。</p>
<p>&nbsp;&nbsp;&nbsp; 5.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 复制并粘贴以下代码来覆盖现有的缺省代码，以定义 Applet 类：</p>
<p>&nbsp;&nbsp;&nbsp; package ncut.zyf.hello;</p>
<p>&nbsp;&nbsp;&nbsp; import java.applet.Applet;</p>
<p>&nbsp;&nbsp;&nbsp; import java.awt.Graphics;</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public class myApplet extends Applet {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public String s;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void init() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = getParameter(\"s\");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (s == null)&nbsp; s = \"nothing\";<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void paint(Graphics g) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g.drawString(s,100,100);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g.drawString(\"Hello applet!\", 50, 25); [Page]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; 三、生成和运行applet源文件：</p>
<p>&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在&#8220;项目&#8221;窗口中右键单击 HelloApplet 项目节点，然后从上下文菜单中选择&#8220;生成项目&#8221;。</p>
<p>&nbsp;&nbsp;&nbsp; 2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将在dist文件夹中创建 HelloApplet.jar 文件。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在&#8220;项目&#8221;窗口中右键单击 Applet 类节点，然后从上下文菜单中选择&#8220;运行文件&#8221;。将在 build 文件夹中创建嵌入了 Applet 的myApplet.html 启动程序文件，并在 Applet 查看器中启动该文件。</p>
<p>&nbsp;&nbsp;&nbsp; 四、通过修改参数来调试applet源文件：</p>
<p>&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 打开&#8220;文件&#8221;窗口 (Ctrl-2)。</p>
<p>&nbsp;&nbsp;&nbsp; 2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将myApplet.html 启动程序文件从 build 文件夹复制到 Applet 类位于src 文件夹的包中（在本例中应复制到nuct.zyf.hello）。请确保 myApplet.html 启动程序文件与 Applet 类具有相同的名称。</p>
<p>&nbsp;&nbsp;&nbsp; 3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 现在根据需要编辑myApplet.html启动程序文件。 在生成项目时,myApplet.html启动程序文件将从 src 文件夹复制到 build 文件夹中。</p>
<p>&nbsp;&nbsp;&nbsp; 五、在 web 应用程序中嵌入 applet：</p>
<p>&nbsp;&nbsp;&nbsp; 1. 创建 web 项目：&nbsp;&nbsp;&nbsp; 选择&#8220;文件&#8221;</p>
<p>&lt;font size="3"&gt;&amp;gt;&lt;/font&gt;&#8220;新建项目&#8221;。在&#8220;类别&#8221;下选择 \"Web\"。在&#8220;项目&#8221;下选择&#8220;Web 应用程序&#8221;。单击&#8220;下一步&#8221;。&nbsp; 在&#8220;项目名称&#8221;下键入 HelloWebApplet。将&#8220;项目位置&#8221;更改为计算机中的任意文件夹。 单击&#8220;完成&#8221;。</p>
<p>&nbsp;&nbsp;&nbsp; 2. 将applet JAR 文件添加到项目中：如果要在 Web 项目中包括 Applet JAR 文件，可以通过添加包含 JAR 文件的 NetBeans IDE 4.1 Java 项目，或者通过添加 JAR 文件自身来执行此操作。在 NetBeans IDE 4.1 Java 项目中修改 Applet 时，只要生成 Web 项目，IDE 都会生成新的 Applet 版本。1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在&#8220;项目&#8221;窗口中，右键单击 HelloWebApplet 项目节点，然后从上下文菜单中选择&#8220;属性&#8221;。</p>
<p><br /><br /></p><img src ="http://www.cppblog.com/deercoder/aggbug/103176.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/deercoder/" target="_blank">刘畅</a> 2009-12-14 13:13 <a href="http://www.cppblog.com/deercoder/articles/103176.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAVA学习（一）</title><link>http://www.cppblog.com/deercoder/articles/102577.html</link><dc:creator>刘畅</dc:creator><author>刘畅</author><pubDate>Fri, 04 Dec 2009 15:40:00 GMT</pubDate><guid>http://www.cppblog.com/deercoder/articles/102577.html</guid><wfw:comment>http://www.cppblog.com/deercoder/comments/102577.html</wfw:comment><comments>http://www.cppblog.com/deercoder/articles/102577.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/deercoder/comments/commentRss/102577.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/deercoder/services/trackbacks/102577.html</trackback:ping><description><![CDATA[<p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" class=MsoNormal align=center><span style="FONT-SIZE: 22pt" lang=EN-US><font face=Calibri>Java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 22pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">学习</span><span style="FONT-SIZE: 22pt" lang=EN-US><o:p></o:p></span></p>
<p style="TEXT-ALIGN: left; TEXT-INDENT: -36pt; MARGIN: 0cm 0cm 0pt 54pt; mso-char-indent-count: 0; mso-list: l0 level1 lfo2" class=MsoListParagraph align=left><span style="FONT-SIZE: 14pt; mso-bidi-font-family: 宋体; mso-bidi-theme-font: minor-fareast" lang=EN-US><span style="mso-list: Ignore"><font face=Calibri>一、</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">编译器的选择。</span><span style="FONT-SIZE: 14pt" lang=EN-US><o:p></o:p></span></p>
<p style="TEXT-ALIGN: left; TEXT-INDENT: 28pt; MARGIN: 0cm 0cm 0pt 21pt; mso-char-indent-count: 2.0; mso-para-margin-left: 2.0gd" class=MsoNormal align=left><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">毋庸置疑，学习</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>Java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">需要一个编译器，至于是命令行和</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>IDE</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">（集成开发环境）则凭用户自身而言，许多高手喜欢用命令行中敲下命令，然后用</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>vim</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">来编辑，不可否认，这样很好，而且如果是</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>linux</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">下面的没有图形界面的话，这个似乎还是唯一的办法，本人现在也正在学习</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>linux</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，有时候也有种恨不得一直都用</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>vim</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">和命令来工作的冲动，不过小弟才疏学浅，所以常常遇到问题，无奈又转回图形界面的拥抱。不过</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>IDE</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的好处是众所周知的，用户界面的产生，确实是极大的方便了我们的工作，虽然掌握</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>IDE</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的各种功能需要一定的时间，不过这个牺牲还是值得的，我认为</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>IDE</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的好处就是可以省去很多麻烦，比如今天我遇到的，多文件的</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的编译，在</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>IDE</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">中，没有任何问题，因为</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>NetBeans</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">中有项目管理，其中做到的工作我不知道，不过如果在命令行中用</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>javac</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">和</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">命令的话，就还是有各种奇怪的错误，各位看到这篇帖子，如果不吝赐教的话，不妨留下言，告诉我如果在命令行下实现多</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">文件的编译。我知道在</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>Netbeans</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">中，有包的管理，所以在一个包下面，我写的每一个类，其实都可以通用，所以就可以自然的实现各个文件直接调用，就像在</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>C++</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">中，我声明文件在</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>.h</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">文件中，而实现可以放在几个</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>.cpp</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">文件中，</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">不需要，只需要把这些</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">文件放在一个包下面，这样就在其他的</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">文件中，只要直接调用就可以了，而没有相应的麻烦，不过这个是</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>IDE</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">中的操纵，具体的命令行，我觉得多少还有些吃力不讨好，何况现在我还是个菜鸟呢！</span><span style="FONT-SIZE: 14pt" lang=EN-US><o:p></o:p></span></p>
<p style="TEXT-ALIGN: left; TEXT-INDENT: 28pt; MARGIN: 0cm 0cm 0pt 21pt; mso-char-indent-count: 2.0; mso-para-margin-left: 2.0gd" class=MsoNormal align=left><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">另外，对于初学者下面这个或许有用。</span><span style="FONT-SIZE: 14pt" lang=EN-US><o:p></o:p></span></p>
<p style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 18pt; mso-char-indent-count: 0; mso-list: l1 level1 lfo1" class=MsoListParagraph><span style="FONT-SIZE: 14pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin" lang=EN-US><span style="mso-list: Ignore"><font face=Calibri>1.</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>Java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">程序为何可以实现跨平台呢？因为</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>JVM</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">（</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>Java Virtual Machine</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">）的存在，具体来说说</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">程序的生成机制吧。首先，用户的</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>.java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">程序，经过编译器（命令行中是</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>javac</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">）的编译，生成</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>.class</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">文件，而这个文件不是能够直接执行的，是一个二进制文件，它需要</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>JVM</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">进行解释执行，这里，解释执行和编译执行时程序执行的两种不同方式。所谓编译执行，就是本机代码经过编译连接之后，在本机形成一个文件，而这个文件的运行，一旦开始，就跟编译器和其他工具无关，具有独立性，可以自己执行。而解释执行呢，就是需要解释器（</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">）来一句一句的执行，解释一句，执行一句，所以可想而知，编译执行的效率要更高一些，而且由于</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">中</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>JVM</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的存在，所以将</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>class</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">文件解释执行，中间的过程可想，速度会慢很多，虽然</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>Sun</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">声称什么高效或者其他，鄙人确实不敢苟同。一个程序的执行跟跑破机子一样，完全没有优越性而言，不过这里那个可移植性，可是很受业界的欢迎的！最后说一句，</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>JVM</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">决定了</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">程序的可移植性，所以一个系统如果不支持</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>JVM</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，那么自然不要指望</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">程序可以移植到这个上面。理解了这个，其实也就知道了这个可移植性的本质了。由于主流系统，</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>windows</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>linux</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>unix</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>Mac</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">都支持，所以就可想其应用之广泛了。注意，</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>JVM</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">模拟的是一个硬件系统，包括指令系统，内存管理&#8230;&#8230;所以虚拟机的概念要清楚。</span><span style="FONT-SIZE: 14pt" lang=EN-US><o:p></o:p></span></p>
<p style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 18pt; mso-char-indent-count: 0; mso-list: l1 level1 lfo1" class=MsoListParagraph><span style="FONT-SIZE: 14pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin" lang=EN-US><span style="mso-list: Ignore"><font face=Calibri>2.</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">安装</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>IDE</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">。</span><span style="FONT-SIZE: 14pt" lang=EN-US><o:p></o:p></span></p>
<p style="TEXT-INDENT: 35pt; MARGIN: 0cm 0cm 0pt; mso-char-indent-count: 2.5" class=MsoNormal><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">注意在进行所有的工作之前，需要做的是先下载</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>jdk</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，从</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>sun</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的网站上下载最新的</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>jdk</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，然后安装之后，你的机子上面才算装了</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>JVM</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，这个时候，默认会为你的系统环境变量设置好它最近的路径。检查的办法很简单，进入命令行，输入</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>javac</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">命令，如果出现了帮助列表，那么说明配置好了，否则就要手动设置了，这里不详细讲解了，读者从网上可以看到巨多。而此时，你可以在命令行中直接工作了，比如进入一个目录，然后创建</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">源程序，同时在确保是该目录下用</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>javac</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">编译，生成</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>class</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">文件，然后用</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>java</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">命令执行相应的</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>class</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">文件，注意不要</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>.class</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">后缀名了。</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>OK</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">。</span><span style="FONT-SIZE: 14pt" lang=EN-US><o:p></o:p></span></p>
<p style="MARGIN: 0cm 0cm 0pt" class=MsoNormal><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes">&nbsp; </span></font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">这里要说的是</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>IDE</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的按照，所以呢，我们需要选择一个</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>IDE</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，比较好的当然是</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>NetBeans</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">和</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>Eclipse</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，但是在安装之前，还是需要装前面介绍的</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>jdk</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，为何，因为这些软件也是基于</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>JVM</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的，所以如果没有</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>JVM</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">，那么就不会顺利安装，更不可能用了。当然，如果你没有装好的，安装过程也会提示的。不过何必呢。正是因为这个机制，所以</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>NetBeans</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的启动慢如蜗牛，</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>Eclipse</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">也好不了多少，这个也是为何我如此厌恶的原因，当然，启动之后</span><span style="FONT-SIZE: 14pt"><font face=Calibri> </font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">就好多了，所以不要常关闭，否则开启的时候还是会等很久的。相比而言，</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>VS 2005</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">就好多了，看了</span><span style="FONT-SIZE: 14pt" lang=EN-US><font face=Calibri>MS</font></span><span style="FONT-FAMILY: 宋体; FONT-SIZE: 14pt; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">的人也不是吃白饭的。当然，本来都不是同一个东西，所以没有可比性，不然高手们又要笑话我了。不过Java的这个缺陷，总是让我有点不平。凭借着强大的类库，我看到了一个新的简单易学，却功能强大的新工具，想比较C++而言，我只能说自己遇到Java太晚了，如果早点碰到Java，或许我可以早点做到很多很好玩的东西，不过不废话了，总之，觉得这个也是Java难以跨越的鸿沟吧，但愿可以更进一步优化吧！<br><br>《未完待续》<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -------------------------------各位和我一起学Java吧！</span></p>
<img src ="http://www.cppblog.com/deercoder/aggbug/102577.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/deercoder/" target="_blank">刘畅</a> 2009-12-04 23:40 <a href="http://www.cppblog.com/deercoder/articles/102577.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAVA初学释疑（待续）</title><link>http://www.cppblog.com/deercoder/articles/102375.html</link><dc:creator>刘畅</dc:creator><author>刘畅</author><pubDate>Wed, 02 Dec 2009 02:56:00 GMT</pubDate><guid>http://www.cppblog.com/deercoder/articles/102375.html</guid><wfw:comment>http://www.cppblog.com/deercoder/comments/102375.html</wfw:comment><comments>http://www.cppblog.com/deercoder/articles/102375.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/deercoder/comments/commentRss/102375.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/deercoder/services/trackbacks/102375.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 最近学校开了JAVA和C++的课，很庆幸暑假的时候看了下C++的书，面向对象的思想虽然不是很透彻的理解，不过理解起来JAVA完全没有任何问题，正如某些人所说的，JAVA就是一个阉割过的C++，不过功能的强大，不得不让人佩服，我不得不承认，如果你想做点好玩的东西出来，那么用JAVA吧，你不需要编写多少代码，而只需要像堆积木一样，组件起来各个组件，就可以堆积成很好的一个程序。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;下面先来谈谈我的一些体会吧，我是根据和C++的比较来学习JAVA的，面向对象的思想，其实程序设计的语言都有这个特点，所以不需要过多的来说明，继承，多态，虚函数等等，都是很重要的。<br>1.基本语法。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JAVA在<br><br><br><br>2.关于运算符的不同。<br>看看下面的这个C/C++代码。
<div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><span style="COLOR: #008080">&nbsp;1</span><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000">&nbsp;std;<br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"><br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;main()<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img id=Codehighlighter1_53_127_Open_Image onclick="this.style.display='none'; Codehighlighter1_53_127_Open_Text.style.display='none'; Codehighlighter1_53_127_Closed_Image.style.display='inline'; Codehighlighter1_53_127_Closed_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_53_127_Closed_Image onclick="this.style.display='none'; Codehighlighter1_53_127_Closed_Text.style.display='none'; Codehighlighter1_53_127_Open_Image.style.display='inline'; Codehighlighter1_53_127_Open_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_53_127_Closed_Text><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_53_127_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;x&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">12</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;y&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">21</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(x&nbsp;</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">&nbsp;y)<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">hello,world</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">&nbsp;endl;<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span></div>
然后看看下面的这个JAVA代码。<br>
<div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><span style="COLOR: #008080">&nbsp;1</span><img id=Codehighlighter1_18_183_Open_Image onclick="this.style.display='none'; Codehighlighter1_18_183_Open_Text.style.display='none'; Codehighlighter1_18_183_Closed_Image.style.display='inline'; Codehighlighter1_18_183_Closed_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_18_183_Closed_Image onclick="this.style.display='none'; Codehighlighter1_18_183_Closed_Text.style.display='none'; Codehighlighter1_18_183_Open_Image.style.display='inline'; Codehighlighter1_18_183_Open_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;Test&nbsp;</span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_18_183_Closed_Text><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_18_183_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&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></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img id=Codehighlighter1_67_180_Open_Image onclick="this.style.display='none'; Codehighlighter1_67_180_Open_Text.style.display='none'; Codehighlighter1_67_180_Closed_Image.style.display='inline'; Codehighlighter1_67_180_Closed_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_67_180_Closed_Image onclick="this.style.display='none'; Codehighlighter1_67_180_Closed_Text.style.display='none'; Codehighlighter1_67_180_Open_Image.style.display='inline'; Codehighlighter1_67_180_Open_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_67_180_Closed_Text><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_67_180_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">12</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;j&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">21</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(x&nbsp;</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">&nbsp;y)<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">hello,world</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"><br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span></div>
前者可以运行，而后者却提示说&amp;&amp;运算符不能用于int ，int类型，说明什么？JAVA进行更严格的类型检查。在《深入理解计算机系统》一书中讲到，&amp;&amp;和&amp;事不同的，这个很容易引起C和C++程序员的错误，为何，&amp;&amp;是逻辑运算符，也就是说左右两边的操作数都必须是bool型变量，而如果你是进行int类型的&amp;&amp;运算，就会将非0的int值解释为true，而0值解释为false，所以实际上我们需要的按位与只能够是&amp;，而不是&amp;&amp;，后者作为条件判断的时候很有用处，便是并且，即AND的作用。而在Java中，错误会提示出来，根本不能够运行，此为其中的一点。 
<img src ="http://www.cppblog.com/deercoder/aggbug/102375.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/deercoder/" target="_blank">刘畅</a> 2009-12-02 10:56 <a href="http://www.cppblog.com/deercoder/articles/102375.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>