Raw use of parameterized class 'ApiResult'
时间: 2023-09-27 10:09:34 浏览: 240
The error message "Raw use of parameterized class 'ApiResult'" typically occurs when you use a generic class without specifying the type parameter.
In Java, when you define a generic class like `ApiResult<T>`, you need to provide the actual type argument when creating an instance of that class. For example, if `T` represents a `String`, you would use `ApiResult<String>`.
Here's an example of how to correctly use the `ApiResult` class with a type parameter:
```java
ApiResult<String> result = new ApiResult<String>();
```
By specifying the type parameter, you are telling the compiler what type of data the `ApiResult` class will operate on. This helps ensure type safety and enables the compiler to perform type checks and provide appropriate compile-time warnings or errors.
Without specifying the type argument, the compiler treats it as a raw type, which can lead to potential type safety issues and unchecked warnings. It's generally recommended to always specify the type parameter when working with generic classes.
阅读全文