自动调用toString方法——

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
//A.java
public class A extends B
{
	public String toString()
	{
		return "A";
	}
}
 
//B.java
public class B
{
	public String toString()
	{
		return "B";
	}
}
 
//C.java
public class C
{
	public static void main(String[] args)
	{
		Object o[] = {new A(), new B()};
 
		System.out.print(o[0]);
		System.out.print(o[1]);
	}
}

Read the rest of this entry »

如果您喜欢本站的内容,欢迎订阅我的RSS以获取本站最新资讯。

大中华局域网用户订阅地址:http://feed.casparant.com/

国际互联网用户订阅地址:http://feeds.casparant.com/casparant