Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当 GSON 反序列化具有 java.util.List 类型的类中的字段时,它似乎倾向于使用 ArrayList 作为要使用的列表实现。有没有办法默认它使用 LinkedList (除了实际将其定义为字段的类型)?
简短的回答是不! 但你仍然可以使用这种结构:
LinkedList<Foo> list = new LinkedList<>( (ArrayList<Foo>) new Gson().fromJson( gsonString, new TypeToken<List<Foo>>(){}.getType() ) );