package com.hanqi;

 public class Test11Car11 {

         //静态
//实例属性
private int m = 0;
//静态属性 //所有实例共有的,在内存里只有一个
private static int n = 0 ; //实例方法
public void run ()
{
for (int i = 0; i < 10; i++)
{
m++; n++; System.out.println("m = "+ m + " n = " + n);
}
}
//静态方法
public static void testStatic()
{ //访问内部成员 //m = 10; n = 10; //run() Test11Car11 t1 = new Test11Car11(); t1.run(); System.out.println("测试静态方法"); //设计模式: 23种,单例模式,工厂模式, }
}
 package com.hanqi;

 public class Test12 {

     public static void main(String[] args) {
// TODO 自动生成的方法存根 Test11Car11 t1 = new Test11Car11();
//实例方法
t1.run(); Test11Car11 t2 = new Test11Car11(); t2.run(); //调用类的静态方法
Test11Car11.testStatic(); //调用类的实例方法
//t1.testStatic();
System.out.println("t3 实例");
Test13 t3 = Test13.instance();
t3.run();
System.out.println("t4 实例");
Test13 t4 = Test13.instance();
t4.run();
} }

学习练习 java 实例属性 静态属性的更多相关文章

  1. java类的静态属性值获取

    获取某个类实例的静态属性: public class ErrorCode { private String code; private String message; private ErrorCod ...

  2. Python学习第十六课——静态属性(property, classmethod, staticmethod)

    计算所居住房子的面积 普通写法 class Room: def __init__(self,name,owner,width,length,heigh): self.name=name self.ow ...

  3. Vue2.x源码学习笔记-Vue静态方法和静态属性整理

    Vue静态方法和静态属性,其实直接在浏览器中可以查看到的,如下 圈起来的是其静态属性,但是有的属性对象中的属性的值又是函数.未圈起来的则是函数. 其实它来自如下各个目录下的js文件 // src/co ...

  4. Day 19:面向对象【类方法】静态属性/静态属性/类方法

    静态属性  @property  class Mom: gender = "woman" def __init__(self,name,weight): self.name = n ...

  5. 面向对象:静态属性,静态方法,组合,继承,衍生,继承之mro线性顺序列表,面向对象综合实例

    1.静态属性(附有装饰器) class Room: def __init__(self,name,owner,width,length,height): self.name=name self.own ...

  6. php静态属性和静态方法

    php静态属性和静态方法 2012-09-29 10:18 1518人阅读 评论(0) 收藏 举报 phpfunction 本php教程主要是学习php中静态属性和静态方法的使用方法和基本的示例. · ...

  7. python静态属性的理解

    python中并没有像 C语言 C++ java 那样定义静态属性的关键字 static 那么在python中是怎么做的呢? class A(object): name="lance&quo ...

  8. day25、 静态属性、类方法、静态方法、组合、继承、

    一. 静态属性.类方法.静态方法 1.1静态属性 class Room: def __init__(self,name,owner,width,length): self.name=name self ...

  9. python - class类 (二) 静态属性/类方法/静态方法

    静态属性: #静态属性 = 数据属性 (@property) class mianji(): def __init__(self,x,y): self.x = x self.y = y #类的函数方法 ...

随机推荐

  1. WeX5和BeX5比较

    http://wex5.com/cn/wex5和bex5比较/ WeX5和BeX5比较 许多对WeX5和BeX5略有了解得人都知道,WeX5和BeX5是完全共用前端框架技术的.但是WeX5和BeX5是 ...

  2. 黄聪:get_posts 函数 | wordpress

    get_posts 函数,简单的来讲是 get_post 的复数新形势,但因为是文章多篇提取,所以使用方法上却略有不同,支持众多参数选择需要提取的文章,在 CMS 主题中经常被用到,当然如果你对 Wo ...

  3. mysql server has gone away 与max_allowed_packed

    今天在本地测试测试给所有店铺批量发信息的功能,大约2万条记录,在本地和备用linux服务器上测试都没有问题,但上windows时一直报mysql server has gone away的错误,搜索一 ...

  4. SharedPreferences实现自动登录记住用户名密码

    最近Android项目需要一个自动登录功能,完成之后,特总结一下,此功能依靠SharedPreferences进行实现.   SharedPreferences简介 SharedPreferences ...

  5. AD按键-矩阵按键:

    原理:利用数组分压+AD采集: 优点:一个IO口可以做成多个按键,节省IO口(矩阵键盘在>4时优点才能体现出来):可备用作为AD基准输入. 缺点:不能做成组合按键(或者电阻要精确选择):且离IO ...

  6. Async/Await - Best Practices in Asynchronous Programming z

    These days there’s a wealth of information about the new async and await support in the Microsoft .N ...

  7. jhat中的OQL(对象查询语言)

    http://blog.csdn.net/wanglha/article/details/40181767 jhat中的OQL(对象查询语言) 如果需要根据某些条件来过滤或查询堆的对象,这是可能的,可 ...

  8. C++学习6

    类是一种数据类型,它类似于普通的数据类型,但是又有别于普通的数据类型.类这种数据类型是一个包含成员变量和成员函数的一个集合. 类的成员变量和普通变量一样,也有数据类型和名称,占用固定长度的内存空间.但 ...

  9. [Flex] ButtonBar系列——labelFunction用户提供的函数,在每个项目上运行以确定其标签

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  10. SQL 去特殊字符

    )) ) as begin declare @i int while patindex('%[^%@+*,=../_ <>''" ^0-9 ^a-Z ^''- ^吖-座]%' , ...