<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1098425610752533766</id><updated>2024-11-01T04:45:03.007-07:00</updated><category term="Array Bounds Checking"/><category term="Array Length in Java"/><category term="Array Sum Activity in Java"/><category term="Arrays Defined"/><category term="Declaring Arrays in java"/><category term="Initializer Lists in java"/><category term="TwoArrays in Java"/><category term="Using a Variable as your index in java"/><title type='text'>What the JAVA?</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://whatthejava.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://whatthejava.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1098425610752533766.post-5727156226301421436</id><published>2011-05-28T23:08:00.000-07:00</published><updated>2011-06-23T00:17:17.297-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TwoArrays in Java"/><title type='text'>TwoArrays in Java</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&amp;nbsp;Two Arrays in Java:Sample program&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public class TwoArrays {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; public static void main(String[] args) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int val[] = {13,-4,82,17};&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int twice[] = new int [4];&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Original Array: &quot;+ val[0]+&quot;,&quot;+val[1]+&quot;,&quot;+val[2]+&quot;,&quot;+val[3]);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //the next line of coude would doulbe the values of val and assign them to twice&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; twice[0] = val[0]*2;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; twice[1] = val[1]*2;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; twice[2] = val[2]*2;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; twice[3] = val[3]*2;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;New Array: &quot;+ twice[0]+&quot;,&quot;+&lt;/i&gt;&lt;i&gt;twice[1]+&quot;,&quot;+&lt;/i&gt;&lt;i&gt;twice[2]+&quot;,&quot;+&lt;/i&gt;&lt;i&gt;twice[3]&lt;/i&gt;&lt;i&gt;);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;//another way to do it&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; twice[0] = val[0]+&lt;/i&gt;&lt;i&gt;val[0]&lt;/i&gt;&lt;i&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; twice[1] = val[1]+&lt;/i&gt;&lt;i&gt;val[1]&lt;/i&gt;&lt;i&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; twice[2] = val[2]+&lt;/i&gt;&lt;i&gt;val[2]&lt;/i&gt;&lt;i&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; twice[3] = val[3]+&lt;/i&gt;&lt;i&gt;val[3]&lt;/i&gt;&lt;i&gt;;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt; System.out.println(&quot;New Array: &quot;+ twice[0]+&quot;,&quot;+&lt;/i&gt;&lt;i&gt;twice[1]+&quot;,&quot;+&lt;/i&gt;&lt;i&gt;twice[2]+&quot;,&quot;+&lt;/i&gt;&lt;i&gt;twice[3]&lt;/i&gt;&lt;i&gt;);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
}&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://whatthejava.blogspot.com/feeds/5727156226301421436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1098425610752533766/5727156226301421436?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/5727156226301421436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/5727156226301421436'/><link rel='alternate' type='text/html' href='http://whatthejava.blogspot.com/2011/05/twoarrays-in-java.html' title='TwoArrays in Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1098425610752533766.post-5856683423186585529</id><published>2011-05-28T22:57:00.000-07:00</published><updated>2011-06-23T00:17:43.788-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array Sum Activity in Java"/><title type='text'>Array Sum Activity in Java</title><content type='html'>&lt;i&gt;//here is an Array Sum sample Activity in Java &lt;/i&gt;&lt;br /&gt;
&lt;i&gt;public class ArraySum {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int[] val = {0, 1, 2, 3};&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int sum = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum = val[0] + val[1] + val[2] + val[3];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Sum of all numbers = &quot; + sum);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://whatthejava.blogspot.com/feeds/5856683423186585529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1098425610752533766/5856683423186585529?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/5856683423186585529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/5856683423186585529'/><link rel='alternate' type='text/html' href='http://whatthejava.blogspot.com/2011/05/array-sum-activity-in-java.html' title='Array Sum Activity in Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1098425610752533766.post-4969185183655334104</id><published>2011-05-28T22:41:00.000-07:00</published><updated>2011-06-23T00:17:54.312-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array Length in Java"/><title type='text'>Array Length in Java</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Array Length in Java&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In order to get the number of elements in an array, you can use the length field of an array. The length field of an array returns the size of the array.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Syntax: &lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayName.length&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Example:&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;i&gt;int[] num = new int [100];&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int counter = 0; counter&amp;lt;num.length; counter++)&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;{&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;System.out.print(num[counter]); &lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;}&amp;nbsp;&lt;/i&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whatthejava.blogspot.com/feeds/4969185183655334104/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1098425610752533766/4969185183655334104?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/4969185183655334104'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/4969185183655334104'/><link rel='alternate' type='text/html' href='http://whatthejava.blogspot.com/2011/05/array-length-in-java.html' title='Array Length in Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1098425610752533766.post-4161818052437866420</id><published>2011-05-28T08:43:00.000-07:00</published><updated>2011-06-23T00:18:04.476-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Initializer Lists in java"/><title type='text'>Initializer Lists in java</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Initializer Lists in java&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;In Java you can declare, construct and initialize an array all in one statemet:&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;int[] data = {23, 38,13,22,-3,0,-25}; //I honestly prefer Initializing Arrays this way &lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;or&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;int[] data = new int []{23, 38,13,22,-3,0,-25};&lt;/i&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whatthejava.blogspot.com/feeds/4161818052437866420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1098425610752533766/4161818052437866420?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/4161818052437866420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/4161818052437866420'/><link rel='alternate' type='text/html' href='http://whatthejava.blogspot.com/2011/05/initializer-lists-in-java.html' title='Initializer Lists in java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1098425610752533766.post-5943440938799657508</id><published>2011-05-28T08:37:00.000-07:00</published><updated>2011-06-23T00:18:20.872-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Using a Variable as your index in java"/><title type='text'>Using a Variable as your index in java</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Using a Variable as your index in java&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;sample code:&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;int x[] = new int [3];&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;int index;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;index = 0;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;x [index]= 1; //this places 1 into x[0]..&amp;nbsp;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;index = 2;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;x[index] = 10; //this places 10 int x[2]..&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;index = 3;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;x[index] = 20;&amp;nbsp;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;//this is an error.. because index 3 is already out of bounds. because you declare x with 3 slots, you are only limited until x[2]..&lt;/i&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whatthejava.blogspot.com/feeds/5943440938799657508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1098425610752533766/5943440938799657508?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/5943440938799657508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/5943440938799657508'/><link rel='alternate' type='text/html' href='http://whatthejava.blogspot.com/2011/05/using-variable-as-your-index-in-java.html' title='Using a Variable as your index in java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1098425610752533766.post-6344148624704797709</id><published>2011-05-28T08:25:00.000-07:00</published><updated>2011-06-23T00:18:29.498-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array Bounds Checking"/><title type='text'>Array Bounds Checking</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Array Bounds Checking&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;- &lt;/span&gt;T&lt;/span&gt;he length of an arra is how many slots it has. An array of length &lt;b&gt;Number &lt;/b&gt;for example has slots indexed 0- (Number -1).&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;-All indexes should be of Integer type.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;-Every-time your compiler says the error. &lt;i&gt;System Out of Bounds&lt;/i&gt; something like that. You should automatically know that the problem is with your array. don&#39;t waste your time by reading all-through-out your program.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whatthejava.blogspot.com/feeds/6344148624704797709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1098425610752533766/6344148624704797709?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/6344148624704797709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/6344148624704797709'/><link rel='alternate' type='text/html' href='http://whatthejava.blogspot.com/2011/05/array-bounds-checking.html' title='Array Bounds Checking'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1098425610752533766.post-689143121872811000</id><published>2011-05-28T08:11:00.000-07:00</published><updated>2011-06-23T00:18:47.434-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Declaring Arrays in java"/><title type='text'>Declaring Arrays</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Declaring Arrays&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Arrays must be declared like variables. When declaring an array, you list the data type, followed by a set of square brackets [], followed by the identifier name.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Example:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;&lt;i&gt;int[] ages;&lt;/i&gt;&lt;/b&gt; or &lt;b&gt;&lt;i&gt;int ages[];&lt;/i&gt;&lt;/b&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; After Declaring, create the array and specify it&#39;s length with a &lt;b&gt;constructor&lt;/b&gt; statement. This process in java is call &lt;b&gt;instantiation. &lt;/b&gt;In order to instantiate an object, use a constructor.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;int ages[];&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;//you declare an array with data type int and identifier ages&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;ages = new int [100]&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;//you declared that ages should contain 100 slots.&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;or you can put-up the two code lines together just like this:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: small;&quot;&gt;int ages[] = new int [100];&lt;/span&gt;&lt;/i&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whatthejava.blogspot.com/feeds/689143121872811000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1098425610752533766/689143121872811000?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/689143121872811000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/689143121872811000'/><link rel='alternate' type='text/html' href='http://whatthejava.blogspot.com/2011/05/declaring-arrays.html' title='Declaring Arrays'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1098425610752533766.post-2673427274062586862</id><published>2011-05-28T07:57:00.000-07:00</published><updated>2011-06-23T00:18:56.302-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays Defined"/><title type='text'>Arrays Defined</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Array Defined&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; An Array stores multiple data items of the same datatype, in a &lt;i&gt;contiguous block of memory&lt;/i&gt;, divided into a number of&amp;nbsp; &lt;i&gt;slots&lt;/i&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Array is an object that is used to store lists of values. It is made out of contiguous block of memory that is divided into a number of slots. Each slots holds a value and all slots has&lt;i&gt; the same data type&lt;/i&gt;. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Arrays have indexes&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Indexes are used to access&amp;nbsp; any of the slots.</content><link rel='replies' type='application/atom+xml' href='http://whatthejava.blogspot.com/feeds/2673427274062586862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1098425610752533766/2673427274062586862?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/2673427274062586862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1098425610752533766/posts/default/2673427274062586862'/><link rel='alternate' type='text/html' href='http://whatthejava.blogspot.com/2011/05/arrays-defined.html' title='Arrays Defined'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>