【发布时间】:2012-02-01 07:18:00
【问题描述】:
我有一个方法返回类型为ArrayList<String>,它也在读取相同类型的参数。现在我如何type cast 或修改我的 BigDecimal 以读取该值?
public static ArrayList<String> currencyUtilArray(ArrayList<String> amountStr ) {
BigDecimal amount = new BigDecimal(ArrayList<String> amountStr);
//How do I define that the amountStr is ArrayList<String> and need to place in BigDecimal amount one after another till the end of the List
return amountStr;
}
或者我需要这样做
【问题讨论】:
-
您是否尝试将
ArrayList<String>转换为ArrayList<BigDecimal>? -
@Gabe 一种方法会调用并发送值列表,现在说两个值,如
1234.5678和4567.1234给这个方法currUtil现在我需要定义我的方法currUtil这样一种读取值并将其逐个放入 BigDecimal 以对其进行处理的方式。如何定义我的方法?
标签: java string casting arraylist bigdecimal