Errors leaded by using the instance varibles

//get a HashMap that maps days to an ArrayList of ips
    
    //there are some bugs here. To be fixed
    
    /*when you write a method that is probably used by other methods, 
    you should wirte it with local variable to avoid some mistakes.
    */

//the two methods use the same instance variables <uiqueIp> 
    public HashMap<String, ArrayList<String>> iPsForDays(){
        ArrayList<String> days = new ArrayList<String>();
        readFile();
        for(LogEntry a: records){
            String date = a.getAccessTime().toString();
            String time = date.substring(4, 10);
            uniqueIp = uniqueIpVisitsOnDay2(time);   
            //If we want to make best use of uniqueIp, the right side should be
            // an ArrayList of ips on different days. 
            IpsOnDays.put(time, uniqueIp);
            System.out.println(IpsOnDays);
        }
        return IpsOnDays;
    }
    
    public ArrayList<String> uniqueIpVisitsOnDay2(String someday){
        
        for(LogEntry a: records){
            String date = a.getAccessTime().toString();
            String time = date.substring(4,10);
            if(time.equals(someday)){
                    uniqueIp.add(a.getIpAddress());   
            }
        }
        return uniqueIp;
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值