package com.shrimpking.t6;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/10/1 14:25
*/
class Graph4<T> {
private T shape;
public T getShape()
{
return shape;
}
public void setShape(T shape)
{
this.shape = shape;
}
}
public class WildcardProblem8_5_2
{
public void display(Graph4<?> graph){
//通配符 ?
System.out.println(graph.getShape());
}
public static void main(String[] args)
{
Graph4<Integer> gaInt = new Graph4<>();
Graph4<String> gaStr = new Graph4<>();
gaInt.setShape(100);
gaStr.setShape("jack");
WildcardProblem8_5_2 wp = new WildcardProblem8_5_2();
wp.display(gaInt);
wp.display(gaStr);
}
}
WildcardProblem8_5_2
最新推荐文章于 2025-01-17 17:49:39 发布
25

被折叠的 条评论
为什么被折叠?



