- 浏览: 190125 次
-
文章分类
最新评论
public class Generic<T> { public Generic() { head = null; tail = null; } public Generic(T head, T tail) { this.head = head; this.tail = tail; } public T getHead() { return head; } public void setHead(T head) { this.head = head; } public T getTail() { return tail; } public void setTail(T tail) { this.tail = tail; } private T head; private T tail; }
public class GenericTest { public static <T extends Comparable> Generic<T> minmax(T[] a) { if (a == null || a.length == 0) { return null; } T max = a[0]; T min = a[0]; for (int i = 1; i < a.length; i++) { if (min.compareTo(a[i]) > 0) { min = a[i]; } if (max.compareTo(a[i]) < 0) { max = a[i]; } } return new Generic<T>(min, max); } public static void main(String[] args) { GregorianCalendar[] date = { new GregorianCalendar(1903,Calendar.FEBRUARY,9), new GregorianCalendar(1815,Calendar.JUNE,18), new GregorianCalendar(1910,Calendar.JULY,9), }; Generic<GregorianCalendar> gg = minmax(date); System.out.println(gg.getHead().getTime()+"\n"+gg.getTail().getTime()); /*String[] words = { "Marry", "Jim", "Xie", "littlep" }; Generic<String> mm = minmax(words); System.out.println("min = " + mm.getHead() + "\n" + "max = " + mm.getTail());*/ } }
发表评论
-
JDK配置
2012-09-19 14:13 662JAVA_HOME C:\Program Files\ ... -
Java abstract class interface 区别
2012-09-09 23:35 9691.abstract class 表示的是一种继承关系,并 ... -
全组合
2012-08-28 23:10 852package cn.xmu.microsoft; ... -
全排列
2012-08-28 11:35 811private static String[] perm ... -
Java 方法引用
2012-08-12 11:23 738一个对象的引用本质上是一个很强的完整和安全方面约束能力的对象指 ... -
Java 动态绑定 静态绑定
2012-08-12 11:07 788静态绑定:使用编译类型的对象引用 动态绑定:使用运行类型所指 ... -
A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available
2012-05-26 15:34 919Eclipse 在 Unbutu下双击图标启动会出现上述问题, ... -
Java BitSet
2012-04-13 09:29 902//说明 bs 至少能够装下65bits 大小由系统 ... -
Java 中文编码问题
2012-04-10 22:09 752import java.io.UnsupportedEn ... -
Hadoop in-mapper combining 实例
2012-04-08 14:46 2574import java.io.IOException; ... -
Java 正则表达式
2012-04-08 09:50 837Pattern p = Pattern.compile( ... -
Java 加载属性配置文件
2012-04-07 16:49 655import java.util.MissingReso ... -
Java notify wait
2012-04-06 09:42 1054wait 和 notify 是Object类而非Thread类 ... -
Dangling meta character '*' near index 0
2012-04-05 14:12 1172这个由于是在java中使用split(“”);造成的,在 ... -
Logger
2012-04-05 08:54 759/LogTest/src/log4j.properties ... -
分割字符串时存在多个分隔符
2012-03-20 17:14 878public static void main(Str ... -
Error: could not open `C:Program FilesJavajre6libamd64jvm.cfg'
2012-02-26 18:55 1051重新配置环境变量后出现可以编译,不可以运行... 删除 ... -
JAVA 运行包中的类
2012-02-23 13:41 1046Java中的包是以目录的形式组织的,在java文件中如果指定了 ... -
Data Access Object
2012-02-18 21:24 730DAO:Data Access Object 把项目开发分为 ... -
文件读写问题
2012-02-16 13:36 717'赵','1234' '钱','2345''孙','3456 ...
相关推荐
Advanced Java Programming is a textbook specially designed for undergraduate and postgraduate students of Computer Science, Information Technology, and Computer Applications (BE/BTech/BCA/ME/M.Tech/...
Java 9 Programming Blueprints .pdf Java 9 Programming Blueprints .pdf
Java Servlet Programming 2nd Edition
本资料“Java Thread Programming”由Paul Hyde提供,包含了关于Java线程编程的理论知识和实践代码,旨在帮助开发者深入理解和熟练掌握Java线程。 首先,我们来了解一下Java中线程的基本概念。在Java中,可以通过两...
Java Network Programming and Distributed Computing
《Java Database Programming Bible》是Java数据库编程领域的一本权威指南,深入浅出地讲解了如何在Java应用程序中与各种数据库进行交互。这本书涵盖了从基础到高级的Java数据库编程技术,旨在帮助开发者熟练掌握...
《Java网络编程》是Elliotte Rusty Harold撰写的一本经典书籍,主要涵盖了Java平台上的网络应用程序开发。这本书深入浅出地介绍了如何使用Java进行网络通信,包括套接字编程、HTTP协议、DNS解析以及多线程等核心概念...
Java Network Programming, 3rd Edition Java Network Programming, 3rd Edition
JXTA-Java P2P Programming pdf
little surprising that network programming in Java remains so mysterious to so many. It doesn’t have to be. In fact, writing network programs in Java is quite simple, as this book will show. Readers ...
little surprising that network programming in Java remains so mysterious to so many. It doesn’t have to be. In fact, writing network programs in Java is quite simple, as this book will show. Readers ...
little surprising that network programming in Java remains so mysterious to so many. It doesn’t have to be. In fact, writing network programs in Java is quite simple, as this book will show. Readers ...
The new third edition of this highly regarded introduction to Java networking programming has been thoroughly revised to cover all of the 100+ significant updates to Java Developers Kit (JDK) 1.5....
the java programming language fourth editionArnoldGoslingHolmes06 Direct from the creators of the Java™ programming language, the completely revised fourth edition of The Java™ Programming Language ...
Java 9 Programming By Example
Java 9 Programming Blueprints 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
become proficient Java programmers A brief version Introduction to Java Programming Brief Version Eighth Edition is available for a first course on programming commonly known as CS1 The brief version ...
Java Extreme Programming Cookbook 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Introduction to java programming 作者:Y.Daniel Liang