java 方法的重载

javax.comm (package). CommPortIdentifier (class) 

方法的重载:方法名一样,参数不一样,返回值不一样,实现不同的功能。

通过不同的参数区别不同的参数调用。

优点:用户只需要记忆少量的方法名,方便

static CommPortIdentifier

getPortIdentifier(CommPort port)
          Obtains the CommPortIdentifier object corresponding to a port that has already been opened by the application.

通过应用程序已经打开的串口获取 CommPortIdentifier  对象。

static CommPortIdentifier

getPortIdentifier(java.lang.String portName)
          Obtains a CommPortIdentifier object by using a port name.

通过串口名获取 CommPortIdentifier 对象。

static java.util.Enumeration

getPortIdentifiers()
          Obtains an enumeration object that contains a CommPortIdentifier object for each port in the system.

获取一个枚举对象包含 系统中每一个串口的CommPortIdentifier 对象。

enumeration 接口中的对象是 CommPortIdentifier.

原文地址:https://www.cnblogs.com/Daluo20200515/p/13215429.html