I want to receive a List as input, Java is showing me no error in:
List<String> A;
ObjectOutputStream ins = new ObjectOutputStream(soc.getOutputStream());
ins.writeObject(A);
The above code executes without error, however this doesn’t:
List<String> ls;
ObjectInputStream in = new ObjectInputStream(soc.getInputStream());
in.readObject(ls);
If I can send a List<>, why cant I accept it? Any reasons and suggestions for the output code?
readObjectdoesn’t take any parameters. You want:(Of course, this isn’t really type-safe, and the compiler should at least raise warnings. How you deal with that is a separate matter.)