<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FCollections%2FCollections_Framework</id>
		<title>Java Tutorial/Collections/Collections Framework - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FCollections%2FCollections_Framework"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Collections/Collections_Framework&amp;action=history"/>
		<updated>2026-05-17T06:20:27Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Collections/Collections_Framework&amp;diff=4670&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Collections/Collections_Framework&amp;diff=4670&amp;oldid=prev"/>
				<updated>2010-06-01T05:04:11Z</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;Версия 05:04, 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://jexp.ru/index.php?title=Java_Tutorial/Collections/Collections_Framework&amp;diff=4669&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Collections/Collections_Framework&amp;diff=4669&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</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;==  Conversion of different Collection data types ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Implementations of the Collection interface normally have a constructor that accepts a Collection object.    &lt;br /&gt;
This enables you to convert a Collection to a different type of Collection, such as a Queue to a List, or a List to a Set, etc. Here are the constructors of some implementations:&amp;lt;/p&amp;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;
public ArrayList (Collection c)&lt;br /&gt;
     public HashSet (Collection c)&lt;br /&gt;
     public LinkedList (Collection c)&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;
&amp;lt;pre class=codeResult&amp;gt;[World, Hello]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Deep clone collection: Returns a new collection containing clones of all the items in the specified collection. ==&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;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but&lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public&lt;br /&gt;
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,&lt;br /&gt;
 * USA.&lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.&lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 * -------------------&lt;br /&gt;
 * ShapeUtilities.java&lt;br /&gt;
 * -------------------&lt;br /&gt;
 * (C)opyright 2003-2008, by Object Refinery Limited and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   -;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: ShapeUtilities.java,v 1.18 2008/06/02 06:58:28 mungady Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes&lt;br /&gt;
 * -------&lt;br /&gt;
 * 13-Aug-2003 : Version 1 (DG);&lt;br /&gt;
 * 16-Mar-2004 : Moved rotateShape() from RefineryUtilities.java to here (DG);&lt;br /&gt;
 * 13-May-2004 : Added new shape creation methods (DG);&lt;br /&gt;
 * 30-Sep-2004 : Added createLineRegion() method (DG);&lt;br /&gt;
 *               Moved drawRotatedShape() method from RefineryUtilities class&lt;br /&gt;
 *               to this class (DG);&lt;br /&gt;
 * 04-Oct-2004 : Renamed ShapeUtils --&amp;gt; ShapeUtilities (DG);&lt;br /&gt;
 * 26-Oct-2004 : Added a method to test the equality of two Line2D&lt;br /&gt;
 *               instances (DG);&lt;br /&gt;
 * 10-Nov-2004 : Added new translateShape() and equal(Ellipse2D, Ellipse2D)&lt;br /&gt;
 *               methods (DG);&lt;br /&gt;
 * 11-Nov-2004 : Renamed translateShape() --&amp;gt; createTranslatedShape() (DG);&lt;br /&gt;
 * 07-Jan-2005 : Minor Javadoc fix (DG);&lt;br /&gt;
 * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG);&lt;br /&gt;
 * 21-Jan-2005 : Modified return type of RectangleAnchor.coordinates()&lt;br /&gt;
 *               method (DG);&lt;br /&gt;
 * 22-Feb-2005 : Added equality tests for Arc2D and GeneralPath (DG);&lt;br /&gt;
 * 16-Mar-2005 : Fixed bug where equal(Shape, Shape) fails for two Polygon&lt;br /&gt;
 *               instances (DG);&lt;br /&gt;
 * 01-Jun-2008 : Fixed bug in equal(GeneralPath, GeneralPath) method (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.Shape;&lt;br /&gt;
import java.awt.geom.AffineTransform;&lt;br /&gt;
import java.awt.geom.Point2D;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Modifier;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
/**&lt;br /&gt;
 * Utility methods for {@link Shape} objects.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
public class Main {&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns a new collection containing clones of all the items in the&lt;br /&gt;
   * specified collection.&lt;br /&gt;
   * &lt;br /&gt;
   * @param collection&lt;br /&gt;
   *          the collection (&amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; not permitted).&lt;br /&gt;
   * @return A new collection containing clones of all the items in the&lt;br /&gt;
   *         specified collection.&lt;br /&gt;
   * @throws CloneNotSupportedException&lt;br /&gt;
   *           if any of the items in the collection cannot be cloned.&lt;br /&gt;
   */&lt;br /&gt;
  public static Collection deepClone(final Collection collection) throws CloneNotSupportedException {&lt;br /&gt;
    if (collection == null) {&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;Null &amp;quot;collection&amp;quot; argument.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    // all JDK-Collections are cloneable ...&lt;br /&gt;
    // and if the collection is not clonable, then we should throw&lt;br /&gt;
    // a CloneNotSupportedException anyway ...&lt;br /&gt;
    final Collection result = (Collection) clone(collection);&lt;br /&gt;
    result.clear();&lt;br /&gt;
    final Iterator iterator = collection.iterator();&lt;br /&gt;
    while (iterator.hasNext()) {&lt;br /&gt;
      final Object item = iterator.next();&lt;br /&gt;
      if (item != null) {&lt;br /&gt;
        result.add(clone(item));&lt;br /&gt;
      } else {&lt;br /&gt;
        result.add(null);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns a clone of the specified object, if it can be cloned, otherwise&lt;br /&gt;
   * throws a CloneNotSupportedException.&lt;br /&gt;
   * &lt;br /&gt;
   * @param object&lt;br /&gt;
   *          the object to clone (&amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; not permitted).&lt;br /&gt;
   * @return A clone of the specified object.&lt;br /&gt;
   * @throws CloneNotSupportedException&lt;br /&gt;
   *           if the object cannot be cloned.&lt;br /&gt;
   */&lt;br /&gt;
  public static Object clone(final Object object) throws CloneNotSupportedException {&lt;br /&gt;
    if (object == null) {&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;Null &amp;quot;object&amp;quot; argument.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    try {&lt;br /&gt;
      final Method method = object.getClass().getMethod(&amp;quot;clone&amp;quot;, (Class[]) null);&lt;br /&gt;
      if (Modifier.isPublic(method.getModifiers())) {&lt;br /&gt;
        return method.invoke(object, (Object[]) null);&lt;br /&gt;
      }&lt;br /&gt;
    } catch (NoSuchMethodException e) {&lt;br /&gt;
      System.out.println(&amp;quot;Object without clone() method is impossible.&amp;quot;);&lt;br /&gt;
    } catch (IllegalAccessException e) {&lt;br /&gt;
      System.out.println(&amp;quot;Object.clone(): unable to call method.&amp;quot;);&lt;br /&gt;
    } catch (InvocationTargetException e) {&lt;br /&gt;
      System.out.println(&amp;quot;Object without clone() method is impossible.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    throw new CloneNotSupportedException(&amp;quot;Failed to clone.&amp;quot;);&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;
==  Framework Interfaces ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The framework consists of four core interfaces with two specializations for sorting&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;Collection&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;List&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Set&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Map&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;SortedSet&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;SortedMap&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Interface type and its implementation ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Interface TypeImplemented bySetHashSet, LinkedHashSet, EnumSetSortedSetTreeSetListVector, Stack, ArrayList, LinkedListQueuePriorityQueue, LinkedListMap&amp;lt;K,V&amp;gt;Hashtable&amp;lt;K,V&amp;gt;, HashMap&amp;lt;K,V&amp;gt;, LinkedHashMap&amp;lt;K,V&amp;gt;, WeakHashMap&amp;lt;K,V&amp;gt;, IdentityHashMap&amp;lt;K,V&amp;gt;SortedMapTreeMap&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Making Your Objects Comparable and Sortable ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You can make objects comparable by implementing the java.lang.ruparable and java.util.ruparator interfaces.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Classes such as java.lang.String, &lt;br /&gt;
java.util.Date, and primitive wrapper classes all implement java.lang.ruparable.&amp;lt;/p&amp;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;
import java.util.Arrays;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    int[] intArray = new int[] { 5, 4, 3, 2, 1 };&lt;br /&gt;
    Arrays.sort(intArray);&lt;br /&gt;
    for (int i : intArray) {&lt;br /&gt;
      System.out.println(i);&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;
&amp;lt;pre class=codeResult&amp;gt;1&lt;br /&gt;
2&lt;br /&gt;
3&lt;br /&gt;
4&lt;br /&gt;
5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  The Collections Framework consists of three parts ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;interfaces, the abstract data types that the framework supports.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;implementations, the concrete versions of these interfaces.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;algorithms,  the predefined actions that can be defined on either the interfaces or their implementations.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;All implementations are unsynchronized.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;All implementations are serializable and cloneable&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;All implementations support having null elements.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The predefined algorithms for supporting the framework are found in the Collections and Arrays classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Using Comparable and Comparator ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;Implementing java.lang.ruparable enables you to define one way to compare instances of your class.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Objects sometimes might be comparable in more ways.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Comparator defines how two objects should be compared.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;To make objects comparable in two ways, you need two comparators.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;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;
import java.util.Arrays;&lt;br /&gt;
import java.util.ruparator;&lt;br /&gt;
class Person implements Comparable {&lt;br /&gt;
  private String firstName;&lt;br /&gt;
  private String lastName;&lt;br /&gt;
  private int age;&lt;br /&gt;
  public String getFirstName() {&lt;br /&gt;
    return firstName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFirstName(String firstName) {&lt;br /&gt;
    this.firstName = firstName;&lt;br /&gt;
  }&lt;br /&gt;
  public String getLastName() {&lt;br /&gt;
    return lastName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setLastName(String lastName) {&lt;br /&gt;
    this.lastName = lastName;&lt;br /&gt;
  }&lt;br /&gt;
  public int getAge() {&lt;br /&gt;
    return age;&lt;br /&gt;
  }&lt;br /&gt;
  public void setAge(int age) {&lt;br /&gt;
    this.age = age;&lt;br /&gt;
  }&lt;br /&gt;
  public int compareTo(Object anotherPerson) throws ClassCastException {&lt;br /&gt;
    if (!(anotherPerson instanceof Person)) {&lt;br /&gt;
      throw new ClassCastException(&amp;quot;A Person object expected.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    int anotherPersonAge = ((Person) anotherPerson).getAge();&lt;br /&gt;
    return this.age - anotherPersonAge;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class LastNameComparator implements Comparator {&lt;br /&gt;
  public int compare(Object person, Object anotherPerson) {&lt;br /&gt;
    String lastName1 = ((Person) person).getLastName().toUpperCase();&lt;br /&gt;
    String firstName1 = ((Person) person).getFirstName().toUpperCase();&lt;br /&gt;
    String lastName2 = ((Person) anotherPerson).getLastName().toUpperCase();&lt;br /&gt;
    String firstName2 = ((Person) anotherPerson).getFirstName().toUpperCase();&lt;br /&gt;
    &lt;br /&gt;
    if (lastName1.equals(lastName2)) {&lt;br /&gt;
      return firstName1.rupareTo(firstName2);&lt;br /&gt;
    } else {&lt;br /&gt;
      return lastName1.rupareTo(lastName2);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class FirstNameComparator implements Comparator {&lt;br /&gt;
  public int compare(Object person, Object anotherPerson) {&lt;br /&gt;
    String lastName1 = ((Person) person).getLastName().toUpperCase();&lt;br /&gt;
    String firstName1 = ((Person) person).getFirstName().toUpperCase();&lt;br /&gt;
    String lastName2 = ((Person) anotherPerson).getLastName().toUpperCase();&lt;br /&gt;
    String firstName2 = ((Person) anotherPerson).getFirstName().toUpperCase();&lt;br /&gt;
    if (firstName1.equals(firstName2)) {&lt;br /&gt;
      return lastName1.rupareTo(lastName2);&lt;br /&gt;
    } else {&lt;br /&gt;
      return firstName1.rupareTo(firstName2);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Person[] persons = new Person[4];&lt;br /&gt;
    persons[0] = new Person();&lt;br /&gt;
    persons[0].setFirstName(&amp;quot;A&amp;quot;);&lt;br /&gt;
    persons[0].setLastName(&amp;quot;X&amp;quot;);&lt;br /&gt;
    persons[0].setAge(56);&lt;br /&gt;
    persons[1] = new Person();&lt;br /&gt;
    persons[1].setFirstName(&amp;quot;S&amp;quot;);&lt;br /&gt;
    persons[1].setLastName(&amp;quot;C&amp;quot;);&lt;br /&gt;
    persons[1].setAge(8);&lt;br /&gt;
    persons[2] = new Person();&lt;br /&gt;
    persons[2].setFirstName(&amp;quot;E&amp;quot;);&lt;br /&gt;
    persons[2].setLastName(&amp;quot;H&amp;quot;);&lt;br /&gt;
    persons[2].setAge(16);&lt;br /&gt;
    persons[3] = new Person();&lt;br /&gt;
    persons[3].setFirstName(&amp;quot;B&amp;quot;);&lt;br /&gt;
    persons[3].setLastName(&amp;quot;Q&amp;quot;);&lt;br /&gt;
    persons[3].setAge(69);&lt;br /&gt;
    System.out.println(&amp;quot;Natural Order&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 4; i++) {&lt;br /&gt;
      Person person = persons[i];&lt;br /&gt;
      String lastName = person.getLastName();&lt;br /&gt;
      String firstName = person.getFirstName();&lt;br /&gt;
      int age = person.getAge();&lt;br /&gt;
      System.out.println(lastName + &amp;quot;, &amp;quot; + firstName + &amp;quot;. Age:&amp;quot; + age);&lt;br /&gt;
    }&lt;br /&gt;
    Arrays.sort(persons, new LastNameComparator());&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    System.out.println(&amp;quot;Sorted by last name&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 4; i++) {&lt;br /&gt;
      Person person = persons[i];&lt;br /&gt;
      String lastName = person.getLastName();&lt;br /&gt;
      String firstName = person.getFirstName();&lt;br /&gt;
      int age = person.getAge();&lt;br /&gt;
      System.out.println(lastName + &amp;quot;, &amp;quot; + firstName + &amp;quot;. Age:&amp;quot; + age);&lt;br /&gt;
    }&lt;br /&gt;
    Arrays.sort(persons, new FirstNameComparator());&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    System.out.println(&amp;quot;Sorted by first name&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 4; i++) {&lt;br /&gt;
      Person person = persons[i];&lt;br /&gt;
      String lastName = person.getLastName();&lt;br /&gt;
      String firstName = person.getFirstName();&lt;br /&gt;
      int age = person.getAge();&lt;br /&gt;
      System.out.println(lastName + &amp;quot;, &amp;quot; + firstName + &amp;quot;. Age:&amp;quot; + age);&lt;br /&gt;
    }&lt;br /&gt;
    Arrays.sort(persons);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    System.out.println(&amp;quot;Sorted by age&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 4; i++) {&lt;br /&gt;
      Person person = persons[i];&lt;br /&gt;
      String lastName = person.getLastName();&lt;br /&gt;
      String firstName = person.getFirstName();&lt;br /&gt;
      int age = person.getAge();&lt;br /&gt;
      System.out.println(lastName + &amp;quot;, &amp;quot; + firstName + &amp;quot;. Age:&amp;quot; + age);&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;
&amp;lt;pre class=codeResult&amp;gt;Natural Order&lt;br /&gt;
X, A. Age:56&lt;br /&gt;
C, S. Age:8&lt;br /&gt;
H, E. Age:16&lt;br /&gt;
Q, B. Age:69&lt;br /&gt;
Sorted by last name&lt;br /&gt;
C, S. Age:8&lt;br /&gt;
H, E. Age:16&lt;br /&gt;
Q, B. Age:69&lt;br /&gt;
X, A. Age:56&lt;br /&gt;
Sorted by first name&lt;br /&gt;
X, A. Age:56&lt;br /&gt;
Q, B. Age:69&lt;br /&gt;
H, E. Age:16&lt;br /&gt;
C, S. Age:8&lt;br /&gt;
Sorted by age&lt;br /&gt;
C, S. Age:8&lt;br /&gt;
H, E. Age:16&lt;br /&gt;
X, A. Age:56&lt;br /&gt;
Q, B. Age:69&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>