- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangleText_2.java
More file actions
Latest commit
41 lines (36 loc) · 556 Bytes
/
Copy pathTriangleText_2.java
File metadata and controls
41 lines (36 loc) · 556 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
classA
{
inta;
intb;
intc;
voidset(inti,intj,intk)
{
a=i;
b=j;
c=k;
}
publicA()//构造无参函数
{
}
publicA (inti,intj, intk)//构造有参函数
{
a=i;
b=j;
c=k;
}
intgirth()
{
return (a+b+c)*2;
}
}
classTriangleText_2
{
publicstaticvoidmain(String[] args)
{
Aaa = newA(4,5,6);//自动访问有参函数,如果不存在会报错
Abb = newA();//自动反问无参函数,默认情况下正确,若单独存在有参函数会报错,两个同时存在会自动辨别
bb.set(2,3,4);
System.out.println(aa.girth());
System.out.println(bb.girth());
}
}