package com.shrimpking.t6;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/10/1 12:17
*/
class Graph2<T>{
private T shape;
public T getShape(){
return this.shape;
}
public void setShape(T shape){
this.shape = shape;
}
}
public class GenericDemo8_4
{
public static void main(String[] args)
{
//泛型,不同实例
Graph2<String> gaStr = new Graph2<>();
Graph2<Integer> gaInt = new Graph2<>();
gaStr.setShape("circle");
gaInt.setShape(999);
System.out.println("ga_str is :" + gaStr.getClass().getName());
System.out.println(gaStr.getShape());
System.out.println("gs_int is :" + gaInt.getClass().getName());
System.out.println(gaInt.getShape());
}
}
GenericDemo8_4
最新推荐文章于 2025-01-16 23:44:38 发布
20

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



