Raw use of parameterized class 'Page'
时间: 2023-09-28 10:08:44 浏览: 61
这是一个编程错误,意味着你直接使用了一个参数化类而没有提供类型参数。在使用参数化类时,必须提供类型参数以便实例化该类。例如,如果你有一个参数化类 `Page<T>`,那么你必须使用 `Page<String>` 或者 `Page<Integer>` 等类型参数来实例化该类。如果你没有提供类型参数,编译器将无法确定如何实例化该类,并且会出现该错误。
相关问题
Raw use of parameterized class
The raw use of a parameterized class refers to using the class without specifying the type parameter. In languages like Java or C#, parameterized classes allow you to create classes that can work with different types. However, if you use the class without specifying the type parameter, it is considered a raw use.
For example, let's say we have a generic class called `Box` that can hold any type of object:
```java
public class Box<T> {
private T value;
public void setValue(T value) {
this.value = value;
}
public T getValue() {
return value;
}
}
```
If we use this class without specifying the type parameter, it becomes a raw use:
```java
Box box = new Box(); // Raw use of Box
box.setValue("Hello"); // No type safety
String value = (String) box.getValue(); // Type casting required
```
In the above example, `Box box = new Box();` is a raw use because we are not specifying the type parameter. This results in the loss of type safety, as we can assign any type of value to the `value` field without any compiler checks. We also need to perform explicit type casting when retrieving the value.
It is generally recommended to avoid raw uses of parameterized classes as they bypass the type safety provided by generics and can lead to runtime errors or unexpected behavior.
Raw use of parameterized class 'ResponseDTO'
The "Raw use of parameterized class 'ResponseDTO'" error typically occurs when a generic class or interface is being used without specifying the type argument. In Java, parameterized classes allow you to define classes that can work with different data types.
To resolve this error, you need to specify the type argument when using the generic class or interface. For example, if you have a class called `ResponseDTO` that takes a type parameter, you need to provide the actual type when creating an instance of that class.
Here's an example of how you can fix the error by specifying the type argument for the `ResponseDTO` class:
```java
ResponseDTO<String> response = new ResponseDTO<>();
```
In this example, the type argument `<String>` specifies that the `ResponseDTO` class will work with `String` objects.
By providing the type argument, you ensure that the generic class is used correctly and avoid the "Raw use of parameterized class" error.