Java Point类move()与setLocation()的比较
我想知道java awt Point类的move(int,int)函数和setLocation(int,int)函数之间是否有显著差异。它们中有没有一个运行得更快,或者在后台有一些疯狂的不同功能。他们似乎做了完全相同的动作——只有一个名字更短
你可以在下面搜索框中键入要查询的问题!
我想知道java awt Point类的move(int,int)函数和setLocation(int,int)函数之间是否有显著差异。它们中有没有一个运行得更快,或者在后台有一些疯狂的不同功能。他们似乎做了完全相同的动作——只有一个名字更短
# 1 楼答案
两者都是一样的。以下是“移动”的作用
下面是“设置位置”的作用
它只调用move方法move只接受整型参数,而setLocation则接受整型、双精度和点型参数
# 2 楼答案
当您对API有疑问时,最好先阅读相关文档
http://docs.oracle.com/javase/7/docs/api/java/awt/Point.html#move(int,%20int)
我想你可以说一个区别是
setLocation
是重载的,允许它接受一个Point
、两个整数或两个double,而move
只接受两个整数