![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/497b48090280646eb6433171df3a4829.png#pic_center)
<script>
**JavaScript中[]、{}、()的区别:{}大括号,表示定义一个对象,大部分情况下要有成对的属性和值,或是函数体。[]中括号,表示一个数组。()多表示参数。**
let p = {
name: "zs",
age: 20,
show: function () {
console.log(this.name + "--" + this.age);
}
}
document.write( p.name);
document.write( p.age);
p.show();
</script>
public class Test {
public static void main(String[] args) {
Person p = new Person("zs",9);
p.getAge();
System.out.println( p.getName());
}
}
class Person{
private String name;
private int age;
public Person() {
}
public Person(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;
}
}