package GenericProgramma;
//定义接口,接口中使用泛型
class Pair<K, V>
{
private static Object Pair;
public K[] getKey;
public V[] getValue;
public Pair()
{
}
public Pair(K[] getKey,V[] getValue)
{
this.getKey = getKey;
this.getValue = getValue;
}
public void showBookInfo()
{
System.out.println("银行名称\t\t存款时间\t户名\t币种\t存款金额\t账户余额");
System.out.println("----------------------------------------------");
for (int i = 0; i <getKey.length;i++)
{
System.out.print(getKey[i]+"\t");
}
}
public static void main(String[] args)
{
String[] info = {"张三","Rmb","8888.00RMB","18,888.88RMB"};
String[] info1 = {"张三","Rmb","8888.00RMB","18,888.88RMB"};
Pair <String,String> book = new Pair<String,String>(info,info1);
book.showBookInfo();
}
}
Java 小白 定义泛型类时声明2个以上数组类型
最新推荐文章于 2023-02-17 10:23:39 发布
这篇博客展示了如何使用Java中的泛型接口来管理银行存款信息。`Pair<K,V>`接口用于存储存款人的姓名、存款币种和金额等关键信息。博客通过实例演示了如何创建和展示存款信息,强调了泛型在数据组织和类型安全方面的优势。

3312

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



