java.util.Enumeration en = javax.comm.CommPortIdentifier.getPortIdentifiers();
int i=0;
while(en.hasMoreElements())
{
portId = (javax.comm.CommPortIdentifier)en.nextElement();
if(portId.getPortType() == javax.comm.CommPortIdentifier.PORT_SERIAL)
{
list.addItem(portId.getName());
i++;
}
}
其中en.nextElement()报错信息如下:
Type safety: The method nextElement() belongs to the raw type Enumeration. References to generic type Enumeration<E> should be parameterized
请问这段代码要如何修改?谢谢.
int i=0;
while(en.hasMoreElements())
{
portId = (javax.comm.CommPortIdentifier)en.nextElement();
if(portId.getPortType() == javax.comm.CommPortIdentifier.PORT_SERIAL)
{
list.addItem(portId.getName());
i++;
}
}
其中en.nextElement()报错信息如下:
Type safety: The method nextElement() belongs to the raw type Enumeration. References to generic type Enumeration<E> should be parameterized
请问这段代码要如何修改?谢谢.
java.util.Enumeration<javax.comm.CommPortIdentifier> en =
javax.comm.CommPortIdentifier.getPortIdentifiers();
int i=0;
while(en.hasMoreElements())
{
portId = en.nextElement();
if(portId.getPortType() == javax.comm.CommPortIdentifier.PORT_SERIAL)
{
list.addItem(portId.getName());
i++;
}
}