当前位置: 首页 > news >正文

超级外链工具 增加外链中昆明网站优化

超级外链工具 增加外链中,昆明网站优化,托管型网站,瑞安微网站建设1.static 修饰符应用范围 static修饰符只能用来修饰类中定义的成员变量、成员方法、代码块以及内部类(内部类有专门章节进行讲解)。 2.static 修饰成员变量 static 修饰的成员变量称之为类变量。属于该类所有成员共享。 示例 package cn.lyxq.test04;public class Chinese…

1.static 修饰符应用范围

static修饰符只能用来修饰类中定义的成员变量、成员方法、代码块以及内部类(内部类有专门章节进行讲解)。

2.static 修饰成员变量

static 修饰的成员变量称之为类变量。属于该类所有成员共享。

示例

package cn.lyxq.test04;public class ChinesePeople {private String name;private  int age;public static String country = "中国";public ChinesePeople(String name,int age){this.name = name;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}
}
package cn.lyxq.test04;public class ChinesePeopleTest {public static void main(String[] args) {ChinesePeople cp1 = new ChinesePeople("张三",20);System.out.println(ChinesePeople.country);ChinesePeople.country="日本";ChinesePeople cp2 = new ChinesePeople("李四",30);System.out.println(ChinesePeople.country);ChinesePeople cp3 = new ChinesePeople("王五",32);System.out.println(ChinesePeople.country);}}

如果类变量是公开的,那么可以使用 类名.变量名 直接访问该类变量

3.static 修饰成员方法

static 修饰的成员方法称之为类方法,属于该类所有成员共享。

package cn.lyxq.test04;public class ChinesePeople {private String name;private  int age;private static String country = "中国";public ChinesePeople(String name,int age){this.name = name;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}//类方法public static String getCountry() {return country;}//类方法public static void setCountry(String country) {ChinesePeople.country = country;}
}
package cn.lyxq.test04;public class ChinesePeopleTest {public static void main(String[] args) {ChinesePeople cp1 = new ChinesePeople("张三",20);ChinesePeople.setCountry("日本");ChinesePeople cp2 = new ChinesePeople("李四",30);System.out.println(ChinesePeople.getCountry());ChinesePeople cp3 = new ChinesePeople("王五",32);System.out.println(cp3.getCountry());//不是最优访问方式}}

如果类方法是公开的,那么可以使用 类名.方法名直接访问该类方法。

4.static 修饰代码块

static 修饰的代码块被称为静态代码块,在JVM第一次记载该类时执行。因此,静态代码代码块只能执行一次,通常用于一些系统设置场景。

package cn.lyxq.test04;public class ChinesePeople {private String name;private  int age;//使用static修饰的成员变量称为类变量,不会随着成员变化而变化,属于所有成员共享private static String country ;//static修饰的代码块称为静态代码块,在JVM第一次加载该类的时候执行,只能执行一次static{country = "中国";System.out.println("country属性已经被赋值");}public ChinesePeople(String name,int age){this.name = name;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}//类方法public static String getCountry() {return country;}//类方法public static void setCountry(String country) {ChinesePeople.country = country;}
}
package cn.lyxq.test04.test;import  cn.lyxq.test04.ChinesePeople;public class ChinesePeopleTest {public static void main(String[] args) {ChinesePeople cp = new ChinesePeople("张三",20);}}

5.static内存

http://www.yayakq.cn/news/442837/

相关文章:

  • 太原网站建设推广服务wordpress 过滤
  • 做网站天通苑沈阳网站制作的公司哪家好
  • 开发网上商城公司seo排名怎么看
  • 网站开发人员是干什么的专门做艺术字的网站
  • 学生作业做网站需要端午节网页制作素材
  • 浙江省城乡和住房建设厅网站建站 seo课程
  • 网站系统后台桂林做网站公司有哪些
  • 广州电力建设有限公司网站百石网怎么做网站
  • 灯箱网站开发做营销网站制作
  • 设计网站页面的工作叫啥网站vr用什么做
  • 网站建设的目的及定位功能网建通信建设有限公司
  • 平台型网站中文网站 可以做谷歌推广吗
  • 网站怎么做黑链接浏阳网站建设tvshown
  • 海南网站运营公司青岛网站推广怎么选
  • 个性化网站建设开发收图片的网站
  • 河南省百城建设提质网站无法连接到wordpress站点
  • 网站制作的公厦门网站seo哪家好
  • 如何在手机上制作网站购物网站起名
  • php做的直播网站商丘 峰少 seo博客
  • 网站建设公司网站定制开发广州公共资源交易中心交易平台
  • 洛阳网站建设价格wordpress博客主题模板
  • 做网站的空间公司营销外包
  • 登陆中国建设银行网站我的账户密码怎么就有了?怎么清除快速排名网站系统
  • 那个网站做外贸重庆企业模板建站信息
  • 可道网站建设软件开发培训方案
  • 单页竞价网站酒店门户网站建设背景
  • 用asp做的网站有多少防水自己如何建设网站
  • 优质的中小型网站建设外贸网站商城建设
  • 男人女人晚上做那事网站发布信息的软件
  • 石家庄网站建设教程响应式网站pad尺寸