当前位置:首页 » 编程博文
开发技术指南» 文章正文
    引言: JAVA的静态变量相当于类字段,而不用理解为对象字段。
 

 

    摘要:一、 填空题(每空1分,共30分)1、根据信号在信道上的传输方向,按数据通信方式分为〈 〉 、〈 〉、〈 〉。2、在osi的管理体系中,定义了五个管理功能,它们是〈 〉、〈 〉、〈 〉、〈 〉、〈 〉。3、面向连接服务具有〈 〉、〈 〉 和〈 〉这三个阶段。4、数据通信是指〈 〉。5、计算机网络的功能主要表现在〈 〉、〈 〉、〈 〉、〈 〉。6、tcp/ip体系共有四个层次,它们是〈 〉、〈 〉、......
    摘要:天气预报:http://appnews.qq.com/cgi-bin/news_qq_search?city=深圳 列车时刻查询:http://www.shike.org.cn/traininfo/index.asp 万年历:http://www.xichang.tv/calendar.htm一些小时钟:http://www.butabon.com/clock/clock_035.swf 可以......


JAVA静态变量

java的静态变量相当于类字段,而不用理解为对象字段.

static fields and methods 【程序编程相关:认识String之二:String与St

【推荐阅读:C# 静态成员和方法的学习小结

in all sample programs that you have seen, the main method is tagged with the static modifier. we are now ready to discuss the meaning of this modifier. 【扩展信息:我在网上看到的,好站!

static fields

if you define a field as static, then there is only one such field per class. in contrast, each object has its own copy of all instance fields. for example, let´s suppose we want to assign a unique identification number to each employee. we add an instance field id and a static field nextid to the employee class:

class employee

{

   . . .

   private int id;

   private static int nextid = 1;

}

now, every employee object has its own id field, but there is only one nextid field that is shared among all instances of the class. let´s put it another way. if there are one thousand objects of the employee class, then there are one thousand instance fields id, one for each object. but there is a single static field nextid. even if there are no employee objects, the static field nextid is present. it belongs to the class, not to any individual object.

 

in most object-oriented programming languages, static fields are called class fields. the term "static" is a meaningless holdover from c++.

 

let´s implement a simple method:

public void setid()

{

   id = nextid;

   nextid++;

}

suppose you set the employee identification number for harry:

harry.setid();

then the id field of harry is set, and the value of the static field nextid is incremented:


...   下一页
    摘要:以csdn为例,在静态新闻/声明添加如下内容,效果如同本页面所示<!-- 时钟clock_035.swf 的035为时钟样式,可自己选择 --> <embed src=http://www.butabon.com/clock/clock_035.swf width=150 height=150 wmode=transparent quality=high loop=true me......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE