Adding each new value of a String 'temp' value to ArrayList without overwriting previous 'temp'

前端 未结 1 973
-上瘾入骨i
-上瘾入骨i 2021-01-29 02:09

My input is coming from a socket using DataInputSteam and because I can have several different String values all being assigned to same clientDay

1条回答
  •  [愿得一人]
    2021-01-29 02:35

    Thanks Prasaanth, that's what I was doing wrong.

    I needed my ArrayList ar = new ArrayList(); to be global and simplified the rest as follows inside my method.

    dataInputStream = new DataInputStream(
                            socket.getInputStream());
       ar.add(dataInputStream.readUTF());
       System.out.print("ar: "+ar);
    

    0 讨论(0)
提交回复
热议问题