上面的例子中,Person是一个类,_init_是一个特殊的方法(init是单词初始化initialization的省略形式),在使用类创建对象之后被执行,用于给新创建的对象初始化属性用。 self.name = name 就是初始化属性的语句 _init_是一个方法,这个方法里面有三个形参self ...
分类:
编程语言 时间:
2020-06-05 18:00:16
阅读次数:
69
所有对象都有_proto_属性,它指向构造该对象的函数的原型对象 比如person._proto_ Person.prototype,这也保证了js所谓的原型继承机制,实例可以获取原型对象中定义的属性和方法。 函数对象有prototype 属性 非函数对象没有 非函数对象 _proto_属性指向构造 ...
分类:
Web程序 时间:
2020-06-05 13:21:06
阅读次数:
76
1.Objects类 1.0 object.equals() 改写equals方法 public class Person/*extends Object*/ { private int age; private String name; public Person() { } public Per ...
分类:
编程语言 时间:
2020-06-05 12:52:50
阅读次数:
69
面向对象三大特征:封装、继承、多态 封装性在java当中的体现: a、方法就是一种封装 b、关键字private也是一种封装 public class Person { String name ; private int age;//使用private修饰,超出本类范围就不能直接使用了 public ...
分类:
编程语言 时间:
2020-06-05 00:50:02
阅读次数:
76
//pointer to structure #include <stdio.h> struct Person { char name[10]; char character[20]; int age; }; void display(struct Person *t); int main() { ...
分类:
其他好文 时间:
2020-06-04 21:27:17
阅读次数:
69
import timeperson_list = ["chb", "wmq", "xxy", "lyp", "wzq"]def ask_way(person_list): print("-" * 60) if len(person_list)== 0 : return"no one can help ...
分类:
其他好文 时间:
2020-06-04 01:44:08
阅读次数:
63
There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th p ...
分类:
其他好文 时间:
2020-06-03 23:34:27
阅读次数:
72
(一)方法引用解释 方法引用通过方法的名字来指向一个方法。 方法引用可以使语言的构造更紧凑简洁,减少冗余代码。 方法引用使用一对冒号 :: (二)代码示例 1 Person类编写 package com.example.demo; import java.time.LocalDate; class ...
分类:
其他好文 时间:
2020-06-03 23:13:06
阅读次数:
66
Scanner类 引用类型 导包 import 包路径.类名称 创建 类名称 对象名=new 类名称() 使用 对象名.成员方法名 匿名对象:只有右边的对象,没有左边的名字和赋值运算符。 new 类名称() new Person.name()="赵又廷"; 匿名对象只能使用唯一的一次,下次再用不得不 ...
html <view class="person-info"> <image class="head-img" src="/images/tmp/demo.png" /> <view class="person-detail"> <view class="user-name"> 张三 <text c ...
分类:
其他好文 时间:
2020-06-03 13:47:31
阅读次数:
61