<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FGenerics%2FConstraints</id>
		<title>Java/Generics/Constraints - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FGenerics%2FConstraints"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Generics/Constraints&amp;action=history"/>
		<updated>2026-04-18T19:35:54Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Generics/Constraints&amp;diff=9183&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Generics/Constraints&amp;diff=9183&amp;oldid=prev"/>
				<updated>2010-06-01T07:27:26Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 07:27, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Generics/Constraints&amp;diff=9182&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Generics/Constraints&amp;diff=9182&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:50Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Bounded Wildcard arguments. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   &lt;br /&gt;
class TwoD {&lt;br /&gt;
  int x, y;&lt;br /&gt;
  TwoD(int a, int b) {&lt;br /&gt;
    x = a;&lt;br /&gt;
    y = b;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class ThreeD extends TwoD {&lt;br /&gt;
  int z;&lt;br /&gt;
  ThreeD(int a, int b, int c) {&lt;br /&gt;
    super(a, b);&lt;br /&gt;
    z = c;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class FourD extends ThreeD {&lt;br /&gt;
  int t;&lt;br /&gt;
  FourD(int a, int b, int c, int d) {&lt;br /&gt;
    super(a, b, c);&lt;br /&gt;
    t = d;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Coords&amp;lt;T extends TwoD&amp;gt; {&lt;br /&gt;
  T[] coords;&lt;br /&gt;
  Coords(T[] o) {&lt;br /&gt;
    coords = o;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class BoundedWildcard {&lt;br /&gt;
  static void showXY(Coords&amp;lt;?&amp;gt; c) {&lt;br /&gt;
    System.out.println(&amp;quot;X Y Coordinates:&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; c.coords.length; i++)&lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + c.coords[i].y);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
  }&lt;br /&gt;
  static void showXYZ(Coords&amp;lt;? extends ThreeD&amp;gt; c) {&lt;br /&gt;
    System.out.println(&amp;quot;X Y Z Coordinates:&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; c.coords.length; i++)&lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + c.coords[i].y + &amp;quot; &amp;quot; + c.coords[i].z);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
  }&lt;br /&gt;
  static void showAll(Coords&amp;lt;? extends FourD&amp;gt; c) {&lt;br /&gt;
    System.out.println(&amp;quot;X Y Z T Coordinates:&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; c.coords.length; i++)&lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + c.coords[i].y + &amp;quot; &amp;quot; + c.coords[i].z + &amp;quot; &amp;quot;&lt;br /&gt;
          + c.coords[i].t);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    TwoD td[] = { new TwoD(0, 0), new TwoD(7, 9), new TwoD(18, 4), new TwoD(-1, -23) };&lt;br /&gt;
    Coords&amp;lt;TwoD&amp;gt; tdlocs = new Coords&amp;lt;TwoD&amp;gt;(td);&lt;br /&gt;
    System.out.println(&amp;quot;Contents of tdlocs.&amp;quot;);&lt;br /&gt;
    showXY(tdlocs); // OK, is a TwoD&lt;br /&gt;
    FourD fd[] = { new FourD(1, 2, 3, 4), new FourD(6, 8, 14, 8), new FourD(22, 9, 4, 9),&lt;br /&gt;
        new FourD(3, -2, -23, 17) };&lt;br /&gt;
    Coords&amp;lt;FourD&amp;gt; fdlocs = new Coords&amp;lt;FourD&amp;gt;(fd);&lt;br /&gt;
    System.out.println(&amp;quot;Contents of fdlocs.&amp;quot;);&lt;br /&gt;
    // These are all OK.&lt;br /&gt;
    showXY(fdlocs);&lt;br /&gt;
    showXYZ(fdlocs);&lt;br /&gt;
    showAll(fdlocs);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Generic cast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (C) 2001-2003 Colin Bell&lt;br /&gt;
 * colbell@users.sourceforge.net&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or&lt;br /&gt;
 * modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
 * License as published by the Free Software Foundation; either&lt;br /&gt;
 * version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
 */&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.text.NumberFormat;&lt;br /&gt;
import java.util.regex.Matcher;&lt;br /&gt;
import java.util.regex.Pattern;&lt;br /&gt;
/**&lt;br /&gt;
 * General purpose utilities functions.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 */&lt;br /&gt;
public class Utilities&lt;br /&gt;
{&lt;br /&gt;
  &lt;br /&gt;
  /**&lt;br /&gt;
  * This is taken from Eammon McManus&amp;quot; blog:&lt;br /&gt;
  * http://weblogs.java.net/blog/emcmanus/archive/2007/03/getting_rid_of.html This prevents you from having&lt;br /&gt;
  * to place SuppressWarnings throughout your code.&lt;br /&gt;
  * &lt;br /&gt;
  * @param &amp;lt;T&amp;gt;&lt;br /&gt;
  *           the return type to cast the object to&lt;br /&gt;
  * @param x&lt;br /&gt;
  *           the object to cast.&lt;br /&gt;
  * @return a type-casted version of the specified object.&lt;br /&gt;
  */&lt;br /&gt;
 @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
 public static &amp;lt;T&amp;gt; T cast(Object x) {&lt;br /&gt;
     return (T) x;&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java generic: Bounded Wildcard arguments ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
 &lt;br /&gt;
// Two-dimensional coordinates. &lt;br /&gt;
class TwoD { &lt;br /&gt;
  int x, y; &lt;br /&gt;
 &lt;br /&gt;
  TwoD(int a, int b) { &lt;br /&gt;
    x = a; &lt;br /&gt;
    y = b; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// Three-dimensional coordinates. &lt;br /&gt;
class ThreeD extends TwoD { &lt;br /&gt;
  int z; &lt;br /&gt;
   &lt;br /&gt;
  ThreeD(int a, int b, int c) { &lt;br /&gt;
    super(a, b); &lt;br /&gt;
    z = c; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// Four-dimensional coordinates. &lt;br /&gt;
class FourD extends ThreeD { &lt;br /&gt;
  int t; &lt;br /&gt;
 &lt;br /&gt;
  FourD(int a, int b, int c, int d) { &lt;br /&gt;
    super(a, b, c); &lt;br /&gt;
    t = d;  &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// This class holds an array of coordinate objects. &lt;br /&gt;
class Coords&amp;lt;T extends TwoD&amp;gt; { &lt;br /&gt;
  T[] coords; &lt;br /&gt;
 &lt;br /&gt;
  Coords(T[] o) { coords = o; } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// Demonstrate a bounded wildcard. &lt;br /&gt;
public class BoundedWildcard { &lt;br /&gt;
  static void showXY(Coords&amp;lt;?&amp;gt; c) { &lt;br /&gt;
    System.out.println(&amp;quot;X Y Coordinates:&amp;quot;); &lt;br /&gt;
    for(int i=0; i &amp;lt; c.coords.length; i++) &lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].y); &lt;br /&gt;
    System.out.println(); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  static void showXYZ(Coords&amp;lt;? extends ThreeD&amp;gt; c) { &lt;br /&gt;
    System.out.println(&amp;quot;X Y Z Coordinates:&amp;quot;); &lt;br /&gt;
    for(int i=0; i &amp;lt; c.coords.length; i++) &lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].y + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].z); &lt;br /&gt;
    System.out.println(); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  static void showAll(Coords&amp;lt;? extends FourD&amp;gt; c) { &lt;br /&gt;
    System.out.println(&amp;quot;X Y Z T Coordinates:&amp;quot;); &lt;br /&gt;
    for(int i=0; i &amp;lt; c.coords.length; i++) &lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].y + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].z + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].t); &lt;br /&gt;
    System.out.println(); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public static void main(String args[]) { &lt;br /&gt;
    TwoD td[] = { &lt;br /&gt;
      new TwoD(0, 0), &lt;br /&gt;
      new TwoD(7, 9), &lt;br /&gt;
      new TwoD(18, 4), &lt;br /&gt;
      new TwoD(-1, -23) &lt;br /&gt;
    }; &lt;br /&gt;
 &lt;br /&gt;
    Coords&amp;lt;TwoD&amp;gt; tdlocs = new Coords&amp;lt;TwoD&amp;gt;(td);     &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(&amp;quot;Contents of tdlocs.&amp;quot;); &lt;br /&gt;
    showXY(tdlocs); // OK, is a TwoD &lt;br /&gt;
//  showXYZ(tdlocs); // Error, not a ThreeD &lt;br /&gt;
//  showAll(tdlocs); // Erorr, not a FourD &lt;br /&gt;
 &lt;br /&gt;
    // Now, create some FourD objects. &lt;br /&gt;
    FourD fd[] = { &lt;br /&gt;
      new FourD(1, 2, 3, 4), &lt;br /&gt;
      new FourD(6, 8, 14, 8), &lt;br /&gt;
      new FourD(22, 9, 4, 9), &lt;br /&gt;
      new FourD(3, -2, -23, 17) &lt;br /&gt;
    }; &lt;br /&gt;
 &lt;br /&gt;
    Coords&amp;lt;FourD&amp;gt; fdlocs = new Coords&amp;lt;FourD&amp;gt;(fd);     &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(&amp;quot;Contents of fdlocs.&amp;quot;); &lt;br /&gt;
    // These are all OK. &lt;br /&gt;
    showXY(fdlocs);  &lt;br /&gt;
    showXYZ(fdlocs); &lt;br /&gt;
    showAll(fdlocs); &lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java generic: Use a wildcard. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
class Stats&amp;lt;T extends Number&amp;gt; {   &lt;br /&gt;
  T[] nums; // array of Number or subclass  &lt;br /&gt;
     &lt;br /&gt;
  // Pass the constructor a reference to    &lt;br /&gt;
  // an array of type Number or subclass.  &lt;br /&gt;
  Stats(T[] o) {   &lt;br /&gt;
    nums = o;   &lt;br /&gt;
  }   &lt;br /&gt;
   &lt;br /&gt;
  // Return type double in all cases.  &lt;br /&gt;
  double average() {   &lt;br /&gt;
    double sum = 0.0;  &lt;br /&gt;
  &lt;br /&gt;
    for(int i=0; i &amp;lt; nums.length; i++)   &lt;br /&gt;
      sum += nums[i].doubleValue();  &lt;br /&gt;
  &lt;br /&gt;
    return sum / nums.length;  &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Determine if two averages are the same. &lt;br /&gt;
  // Notice the use of the wildcard. &lt;br /&gt;
  boolean sameAvg(Stats&amp;lt;?&amp;gt; ob) { &lt;br /&gt;
    if(average() == ob.average())  &lt;br /&gt;
      return true; &lt;br /&gt;
 &lt;br /&gt;
    return false; &lt;br /&gt;
  } &lt;br /&gt;
}   &lt;br /&gt;
   &lt;br /&gt;
// Demonstrate wildcard. &lt;br /&gt;
public class WildcardDemo {   &lt;br /&gt;
  public static void main(String args[]) {   &lt;br /&gt;
    Integer inums[] = { 1, 2, 3, 4, 5 };  &lt;br /&gt;
    Stats&amp;lt;Integer&amp;gt; iob = new Stats&amp;lt;Integer&amp;gt;(inums);    &lt;br /&gt;
    double v = iob.average();  &lt;br /&gt;
    System.out.println(&amp;quot;iob average is &amp;quot; + v);  &lt;br /&gt;
  &lt;br /&gt;
    Double dnums[] = { 1.1, 2.2, 3.3, 4.4, 5.5 };  &lt;br /&gt;
    Stats&amp;lt;Double&amp;gt; dob = new Stats&amp;lt;Double&amp;gt;(dnums);    &lt;br /&gt;
    double w = dob.average();  &lt;br /&gt;
    System.out.println(&amp;quot;dob average is &amp;quot; + w);  &lt;br /&gt;
  &lt;br /&gt;
    Float fnums[] = { 1.0F, 2.0F, 3.0F, 4.0F, 5.0F };  &lt;br /&gt;
    Stats&amp;lt;Float&amp;gt; fob = new Stats&amp;lt;Float&amp;gt;(fnums);    &lt;br /&gt;
    double x = fob.average();  &lt;br /&gt;
    System.out.println(&amp;quot;fob average is &amp;quot; + x);  &lt;br /&gt;
  &lt;br /&gt;
    // See which arrays have same average. &lt;br /&gt;
    System.out.print(&amp;quot;Averages of iob and dob &amp;quot;); &lt;br /&gt;
    if(iob.sameAvg(dob)) &lt;br /&gt;
      System.out.println(&amp;quot;are the same.&amp;quot;);  &lt;br /&gt;
    else &lt;br /&gt;
      System.out.println(&amp;quot;differ.&amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    System.out.print(&amp;quot;Averages of iob and fob &amp;quot;); &lt;br /&gt;
    if(iob.sameAvg(fob)) &lt;br /&gt;
      System.out.println(&amp;quot;are the same.&amp;quot;);  &lt;br /&gt;
    else &lt;br /&gt;
      System.out.println(&amp;quot;differ.&amp;quot;);  &lt;br /&gt;
  }   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use a wildcard. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
class Stats&amp;lt;T extends Number&amp;gt; {&lt;br /&gt;
  T[] nums;&lt;br /&gt;
  Stats(T[] o) {&lt;br /&gt;
    nums = o;&lt;br /&gt;
  }&lt;br /&gt;
  double average() {&lt;br /&gt;
    double sum = 0.0;&lt;br /&gt;
    for (int i = 0; i &amp;lt; nums.length; i++)&lt;br /&gt;
      sum += nums[i].doubleValue();&lt;br /&gt;
    return sum / nums.length;&lt;br /&gt;
  }&lt;br /&gt;
  boolean sameAvg(Stats&amp;lt;?&amp;gt; ob) {&lt;br /&gt;
    if (average() == ob.average())&lt;br /&gt;
      return true;&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class WildcardDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Integer inums[] = { 1, 2, 3, 4, 5 };&lt;br /&gt;
    Stats&amp;lt;Integer&amp;gt; iob = new Stats&amp;lt;Integer&amp;gt;(inums);&lt;br /&gt;
    double v = iob.average();&lt;br /&gt;
    System.out.println(&amp;quot;iob average is &amp;quot; + v);&lt;br /&gt;
    Double dnums[] = { 1.1, 2.2, 3.3, 4.4, 5.5 };&lt;br /&gt;
    Stats&amp;lt;Double&amp;gt; dob = new Stats&amp;lt;Double&amp;gt;(dnums);&lt;br /&gt;
    double w = dob.average();&lt;br /&gt;
    System.out.println(&amp;quot;dob average is &amp;quot; + w);&lt;br /&gt;
    Float fnums[] = { 1.0F, 2.0F, 3.0F, 4.0F, 5.0F };&lt;br /&gt;
    Stats&amp;lt;Float&amp;gt; fob = new Stats&amp;lt;Float&amp;gt;(fnums);&lt;br /&gt;
    double x = fob.average();&lt;br /&gt;
    System.out.println(&amp;quot;fob average is &amp;quot; + x);&lt;br /&gt;
    // See which arrays have same average.&lt;br /&gt;
    System.out.print(&amp;quot;Averages of iob and dob &amp;quot;);&lt;br /&gt;
    if (iob.sameAvg(dob))&lt;br /&gt;
      System.out.println(&amp;quot;are the same.&amp;quot;);&lt;br /&gt;
    else&lt;br /&gt;
      System.out.println(&amp;quot;differ.&amp;quot;);&lt;br /&gt;
    System.out.print(&amp;quot;Averages of iob and fob &amp;quot;);&lt;br /&gt;
    if (iob.sameAvg(fob))&lt;br /&gt;
      System.out.println(&amp;quot;are the same.&amp;quot;);&lt;br /&gt;
    else&lt;br /&gt;
      System.out.println(&amp;quot;differ.&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>