<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=Talk%3ASE251%3AQuestions_%26_Answers</id>
	<title>Talk:SE251:Questions &amp; Answers - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=Talk%3ASE251%3AQuestions_%26_Answers"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=Talk:SE251:Questions_%26_Answers&amp;action=history"/>
	<updated>2026-05-20T12:58:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=Talk:SE251:Questions_%26_Answers&amp;diff=13951&amp;oldid=prev</id>
		<title>Mark: 2 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=Talk:SE251:Questions_%26_Answers&amp;diff=13951&amp;oldid=prev"/>
		<updated>2008-11-03T10:43:37Z</updated>

		<summary type="html">&lt;p&gt;2 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== When to use Arrays and Lists ==&lt;br /&gt;
&lt;br /&gt;
Someone has suggested using arrays to represent the Transactions and suggested the following code. &lt;br /&gt;
 private Transaction[] transactionHistory;&lt;br /&gt;
 private int numberOfTransactions;&lt;br /&gt;
&lt;br /&gt;
 transactionHistory[ numberOfTransactions++ ] = new Transaction( ... );&lt;br /&gt;
&lt;br /&gt;
There is one (&amp;#039;&amp;#039;big&amp;#039;&amp;#039;) problem with that - arrays are of fixed size. Once you initialize an array (giving its size or putting items into it) you &amp;#039;&amp;#039;&amp;#039;cannot change the size of that array object&amp;#039;&amp;#039;&amp;#039;. You can fake a dynamically expanding array using&lt;br /&gt;
 System.arrayCopy(...)&lt;br /&gt;
method. But its very tedious and not a very efficient way of doing it. (e.g. you&amp;#039;ll have to keep checking that the array is not yet full each time you are adding a Transaction object)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; (and any java.utils.Collection class) already takes care of this for you - so why try to re-invent the wheel?&lt;br /&gt;
&lt;br /&gt;
Remember these two simple guidelines when deciding what data structure to use to represent a group of objects:&lt;br /&gt;
:* Use arrays (fixed size) if your collection&amp;#039;s size is not going to change&lt;br /&gt;
:* Use a List (e.g. ArrayList, Vector etc) if your collection will change in size (or you don&amp;#039;t know its size when you are initializing the instance).&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>