I've been looking into creating a barcode scanner program, and in my research I came across something I've never seen before, and I'm not sure exactly what it is doing...
Here's a snippet of my program, including the line I don't understand:
import javax.comm.*;
public class InvScan implements SerialPortEventListener {
static CommPortIdentifier portId1;
SerialPort serialPort1;
public InvScan(){
serialPort1 = (SerialPort) portId1.open("InvScan", 2000); //what does this mean?
}
See the line where I commented "what does this mean?". SerialPort is an abstract class... I know abstract classes can be instantiated using an anonymous class, but I've never seen this before. This line of code came from a tutorial for a program designed to do something related to what I want to do, but the author didn't explain what is going on here very well (or maybe I just didn't understand?). His notes say:
we are instantiating the SerialPort object by executing portId1’s open() method. Recall portId1 is a ComPortIdentifier object and the open() method comes from ComPortIdentifier.
I've done some research, and I can't even find another example of whatever is going on here (probably because I don't even know what to call it, really).
This isn't even really essential to my program, as I can just redesign it (and not be a script kiddie, haha), but it's really bugging me that I don't know what is going on in that line.