⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 14.htm

📁 里面是java applet小应用程序的实例
💻 HTM
字号:
<html><!-- #BeginTemplate "/Templates/empolder_doc.dwt" -->
<head>
<!-- #BeginEditable "doctitle" --> 
<title>|&gt;&lt;| 太平洋电脑信息网 -&gt; 网络学院 -&gt; 开发教室</title>
<!-- #EndEditable --> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
-->
</style>
<link rel="stylesheet" href="/pcedu/style/text.css"></head>

<body bgcolor="#FFFFFF" topmargin=0 leftmargin=0 marginheight="0">
<script language="JavaScript" src="/pcedu/script/top.js">
</script>
<table width=760 border=0 cellspacing=0 cellpadding=0 align=center>
  <tr> 
    <td width=194 height="56"><a href=http://www.pconline.com.cn><img src=http://www.pconline.com.cn/images/pconlinelogo.gif width=162 height=35 vspace=10 border=0></a></td>
    <td width=406 height="56">
      <script language="JavaScript" src="/pcedu/script/empolder_ad.js">
</script>
    </td>
    <td width=158 align=right height="56">
      <script language="JavaScript" src="/pcedu/script/empolder_ad1.js">
</script>
    </td>
    <td align=right width=2 height="56">&nbsp;</td>
  </tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=760 align="center">
  <tbody> 
  <tr valign=bottom> 
    <td rowspan=2 width=172><img height=32 src="/pcedu/images/pcedu_lo.gif" 
      width=172 border="0"></td>
    <td height=30 rowspan=2> 
      <table cellpadding=0 cellspacing=0 width="588" bgcolor="#FFA000" background="/pcedu/images/e_menu5.gif" border="0">
        <tbody> 
        <tr valign="bottom"> 
          <td height="17"> 
            <script language="JavaScript" src="/pcedu/script/title_empolder.js">
</script>
          </td>
        </tr>
        </tbody> 
      </table>
    </td>
  </tr>
  <tr></tr>
  <tr bgcolor="#303880"> 
    <td colspan=2 height=1 valign=bottom><img height=1 
      src="/pcedu/images/blank.gif" width=1></td>
  </tr>
  <tr> 
    <td colspan=2 height=5 valign=bottom><img height=5 
      src="/pcedu/images/blank.gif" width=1></td>
  </tr>
  </tbody> 
</table>
<table width="760" cellspacing="0" cellpadding="0" align="center" height="37">
  <tr> 
    <td width="170" valign="top"> 
      <table border="0" width="170" height="100%"
    cellspacing="1" bgcolor="#000000">
        <tr bgcolor="#F8F8D2"> 
          <td width="100%" valign="top"><!-- #BeginEditable "left" --> 
            <div align="center"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" align="center">
                <tr bgcolor="#E17329"> 
                  <td height="20" align="center"><font color="#FFFFFF">==<b>开发教室==</b></font></td>
                </tr>
              </table>
              <br>
            </div>
            <!-- #EndEditable -->
            <script language="JavaScript" src="/pcedu/script/left_empolder.js">
</script>
          </td>
        </tr>
      </table>
    </td>
    <td width="10"><img src="/pcedu/images/blank.gif" width="1" height="1"></td>
    <td width="580" valign="top" class="article"> 
      <p><img src="/pcedu/images/666666.gif" width="99%" height="1"></p>
      <!-- #BeginEditable "content" --> 
      <center>
        <center>
          <center>
          </center>
          <p align="center" class="title">Java Applet 入门</p>
          <p align="right"><a href="mailto:yy435@263.net">yy435</a></p>
          <p align="right">太平洋网络学院</p>
          <p class="green">第二天</p>
          <p align="left"><span class="green">4.数 组</span></p>
        </center>
      </center>
      <p>数组是长常用的数据结构,相同的数据类型元素类型按一定的顺序排列就构成了数组,在Java中数组元素可以是简单数据类型的量,也可以是某一类的对象。数组的主要特点有三个:</p>
      <p>1)数组是相同数据类型的元素的集合。<br>
        2)数组中的各元素是有先后顺序的,他们在内存中按照这个先后顺序连续存放在一起。<br>
        3)每个数组元素用整个的名字和它自己在数组中的顺序位置表达,例如a[0]就代表名为a的数组中的第一个元素,a[1]就就代表数组a的第二个元素,依此类推。</p>
      <p>Java数组需要下面三个步骤:这与其他的语言相比,有一定的差异。</p>
      <p> 1)声明数组<br>
        声明数组主要是声明数组的名称和数组所包含的元素的数据类型或元素的类名。声明数组的语法格式有两种如下:<br>
        数组元素类型 &nbsp;&nbsp;数组名[];<br>
        数组元素类型[]&nbsp;数组名; <br>
        方括号[]是数组的标志,它可以出现在数组名的后面,也可以出现在数组元素类型的后面,两种定义方法没有什么差别。</p>
      <p>2)创建数组空间<br>
        声明数组仅仅指定数组的名字和数组元素的类型,要想真正使用数组还需要为它开辟内存空间,即创建数组空间。与多数语言一样,Java不支持没有定义元素个数的数组,在创建数组空间时必须为它指明数组的长度。以确定精确的内存空间的大小。语法格式为:<br>
        数组名 = new 数组元素类型[数组元素的个数];<br>
        例如:<br>
        MyIntArray[] =new int[10];<br>
        创建数组空间的工作也可以与声明数组合在一起,用一条语句完成,例如:<br>
        int MyIntArray = new int[10];<br>
        你也可以在创建数组空间的时候,同时将初值给出来,例如:<br>
        int MyIntArray[]={1,2,3,4,5,6,7,8,9};<br>
        这样就创建了一个包含10个整型元素的数组,同时给出了每个元素的初值。</p>
      <p>3)初始化数组元素<br>
        如果是基本的数据类型,那么这个步骤可以自行省略。因为基本数据类型量都有缺省的。也可以象上面一样,直接在创建数组空间的时候,就将它初始化。如果是类,则将比较麻烦了。以后在讲类的时候再说!</p>
      <p>给大家举下面一个例子:<br>
      </p>
      <table width="570" border="1" bordercolor="#FF9966">
        <tr> 
          <td width="438"> 
            <pre>
import java.awt .*;
import java.applet.*;

public class ShuZu extends Applet 
{
int MyIntArray[]={1,2,3,4,5,6,7,8,9,10};
public void paint(Graphics g)
{
g.drawString ("MyIntArray[0]="+MyIntArray[0],2,15);
g.drawString ("MyIntArray[1]="+MyIntArray[1],2,30);
g.drawString ("MyIntArray[2]="+MyIntArray[2],2,45);
g.drawString ("MyIntArray[3]="+MyIntArray[3],2,60);
g.drawString ("MyIntArray[4]="+MyIntArray[4],2,75);
g.drawString ("MyIntArray[5]="+MyIntArray[5],2,90);
g.drawString ("MyIntArray[6]="+MyIntArray[6],2,105);
g.drawString ("MyIntArray[7]="+MyIntArray[7],2,120);
g.drawString ("MyIntArray[8]="+MyIntArray[8],2,135);
g.drawString ("MyIntArray[9]="+MyIntArray[9],2,150);
	}
}
</pre>
          </td>
          <td width="212"><applet code="ShuZu.class" width="250" height="300">
            </applet></td>
        </tr>
      </table>
      <p align="center"><a href="13.htm">[上一页]</a> <a href="15.htm">[下一页]</a></p>
      <!-- #EndEditable --> 
      <table width="100%" border="0">
          <tr class="sfont"> 
            <td>
              <div align="center"><a href="javascript:history.go(-1)">[返回]</a>
              </div>
            </td>
          </tr>
        </table>
      </td>
  </tr>
</table>
<hr noshade size="2" width="760">
<div align="center"> 
  <p align="center"><font color="#000000"> 
    <script language="JavaScript" src="/pcedu/script/title_edu.js">
</script>
    </font> <br>
    <br>
    版权所有&copy;2000 太平洋电脑网<br>
    <font face="Arial, Helvetica, sans-serif"> 
    <script>
document.write("<a href=http://best.netease.com/cgi-bin/view/viewbasic.cgi?exp target=_blank><img src=http://best.netease.com/cgi-bin/log.cgi?user=exp&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+" border=0 alt='网易中文排行榜' width=1 height=1></a>");
</script>
    <a href=mailto:webmaster@pconline.com.cn> </a></font><font face="Arial, Helvetica, sans-serif"><a href=mailto:webmaster@pconline.com.cn>webmaster@pconline.com.cn</a></font><font face="Arial, Helvetica, sans-serif"><a href=mailto:webmaster@pconline.com.cn> 
    <script language="">document.write("<a href=http://best.netease.com/cgi-bin/view/viewbasic.cgi?pconline1 target=_blank><img src=http://best.netease.com/cgi-bin/log.cgi?user=pconline1&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+" border=0 width=1 height=1 ></a>");</script>
    </a> 
    <script language="">
document.write("<a href=http://count.pconline.com.cn/admin/index.php target=_blank><img src=http://count.pconline.com.cn/count.php?user=pcedu&refer="+escape(document.referrer)+" border=0 width=0 height=0 alt='' ></a>");
</script>
    </font> </p>
    </div>
 
</body>
<!-- #EndTemplate --></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -