如何将对象强制转换为Arraylist

时间:2015-10-25 03:26:03

标签: java object arraylist

我需要将一个Object转换为Arraylist:

with open("path/to/input") as infile, open("path/to/output", 'w') as outfile:
    months = {}
    for line in infile:
        month, val = line.strip().split(',')
        val = float(val)
        month = month[:3]
        if month not in months:
            months[month] = 0
        months[month] += val
    for month in 'jan feb mar apr may jun jul aug sep oct nov dec'.split():
        outfile.write(','.join([month, str(months[month])))

1 个答案:

答案 0 :(得分:2)

假设它是ArrayList,你可以投了它(我推荐List界面)

List<Products> mypr = (List<Products>) sesion.getAttribute("products");
相关问题