<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.theeggeadventure.com/wikimedia/index.php?action=history&amp;feed=atom&amp;title=Java_Version</id>
	<title>Java Version - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.theeggeadventure.com/wikimedia/index.php?action=history&amp;feed=atom&amp;title=Java_Version"/>
	<link rel="alternate" type="text/html" href="https://www.theeggeadventure.com/wikimedia/index.php?title=Java_Version&amp;action=history"/>
	<updated>2026-05-22T07:39:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0-beta</generator>
	<entry>
		<id>https://www.theeggeadventure.com/wikimedia/index.php?title=Java_Version&amp;diff=1828&amp;oldid=prev</id>
		<title>Egge: New page: A frequent computer science problem is comparing version numbers.  Version numbers are like decimal numbers with multiple decimal points.  One can not accurately compare version numbers as...</title>
		<link rel="alternate" type="text/html" href="https://www.theeggeadventure.com/wikimedia/index.php?title=Java_Version&amp;diff=1828&amp;oldid=prev"/>
		<updated>2008-03-05T02:35:49Z</updated>

		<summary type="html">&lt;p&gt;New page: A frequent computer science problem is comparing version numbers.  Version numbers are like decimal numbers with multiple decimal points.  One can not accurately compare version numbers as...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A frequent computer science problem is comparing version numbers.  Version numbers are like decimal numbers with multiple decimal points.  One can not accurately compare version numbers as a string or a number.  Often you want to see if a version is later than another version.  Here&amp;#039;s a Java class which goes about solving this problem.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;geshi lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class Version implements Comparable, Serializable {&lt;br /&gt;
	private final int version[];&lt;br /&gt;
&lt;br /&gt;
	public Version(String version) {&lt;br /&gt;
		String[] split = version.split(&amp;quot;\\.&amp;quot;);&lt;br /&gt;
		this.version = new int[split.length];&lt;br /&gt;
		for (int i = 0; i &amp;lt; split.length; i++) {&lt;br /&gt;
			String string = split[i];&lt;br /&gt;
			this.version[i] = Integer.valueOf(string).intValue();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	private static final long serialVersionUID = 5028475470314950450L;&lt;br /&gt;
&lt;br /&gt;
	public int compareTo(Object o) {&lt;br /&gt;
		if (this == o)&lt;br /&gt;
			return 0;&lt;br /&gt;
		final int[] other = ((Version) o).version;&lt;br /&gt;
		int length = Math.max(version.length, other.length);&lt;br /&gt;
		for(int i = 0; i &amp;lt; length; i++) {&lt;br /&gt;
			int x = (i &amp;lt; version.length) ? version[i] : 0;&lt;br /&gt;
			int y = (i &amp;lt; other.length) ? other[i] : 0;&lt;br /&gt;
			if (x &amp;lt; y)&lt;br /&gt;
				return -1;&lt;br /&gt;
			if (x &amp;gt; y)&lt;br /&gt;
				return 1;&lt;br /&gt;
		}&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public int hashCode() {&lt;br /&gt;
		final int prime = 31;&lt;br /&gt;
		int result = 1;&lt;br /&gt;
		result = prime * result + Version.hashCode(version);&lt;br /&gt;
		return result;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public boolean equals(Object obj) {&lt;br /&gt;
		if (this == obj)&lt;br /&gt;
			return true;&lt;br /&gt;
		if (obj == null)&lt;br /&gt;
			return false;&lt;br /&gt;
		if (getClass() != obj.getClass())&lt;br /&gt;
			return false;&lt;br /&gt;
		final Version other = (Version) obj;&lt;br /&gt;
		if (!Arrays.equals(version, other.version))&lt;br /&gt;
			return false;&lt;br /&gt;
		return true;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	private static int hashCode(int[] array) {&lt;br /&gt;
		final int prime = 31;&lt;br /&gt;
		if (array == null)&lt;br /&gt;
			return 0;&lt;br /&gt;
		int result = 1;&lt;br /&gt;
		for (int index = 0; index &amp;lt; array.length; index++) {&lt;br /&gt;
			result = prime * result + array[index];&lt;br /&gt;
		}&lt;br /&gt;
		return result;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public String toString() {&lt;br /&gt;
		String s = &amp;quot;&amp;quot;;&lt;br /&gt;
		for (int i = 0; i &amp;lt; version.length; i++) {&lt;br /&gt;
			if (!&amp;quot;&amp;quot;.equals(s))&lt;br /&gt;
				s += &amp;quot;.&amp;quot;;&lt;br /&gt;
			s += Integer.toString(version[i]);&lt;br /&gt;
		}&lt;br /&gt;
		return s;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Egge</name></author>
	</entry>
</feed>