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

前端 未结 1 974
-上瘾入骨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<String> ar = new ArrayList<String>(); 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)
提交回复
热议问题