This Is The Read Day 18 of Javatober by run.vince.run

View this thread on steempeak.com
· @run.vince.run ·
$1.36
This Is The Read Day 18 of Javatober
<h2>I Did Two Day 16's By Accident</h2>

![background-code-coder-177598.jpg](https://cdn.steemitimages.com/DQmfYPyF6xkcXGZrZGNvNEyBHuBWRjEpjj7W7bPHeYuAMEJ/background-code-coder-177598.jpg)
[Image courtesy of pexels.com](pexels.com)

We did a brief discussion earlier on data structures and we touched on arrays just quickly, but today for day 17, I thought it was time I went a little deaper with arrays. I haven't used arrays as much as what I would with other languages, so I am not sure if they are still relelvant with the Java language. It seems they were used more in the times that the String library was not as advanced in Java as what it is today and were used to carry strings with one character as each item in the array.

<h2>What Did I Learn Today</h2>
An array in Java is a data structure that stores a sequential collection of elements of the same type. You must declare a variable to reference the array, and you must specify the type of array the variable can reference, so in the example below we specify the data type and then the name of the variable:

```dataType[] arrayRef;```

Or if you wanted to create an array of doubles:

```double[] myList;```

You then can create your array in the same way you would create an object of a class with the new operator:

```dataType[] arrayName = new dataType[arraySize];```

In our previous example, we would use the following to create an array:

```double[] myList = new double[10];```

Instead of using the new operator, we can create an array and fill it with values at the same time like so:

```double[] myList = {1.0, 2.2, 3.2, 4.1 };```

To process array elements we can then use a for loop or foreach loop because all of the elements in an array are of the same type and the size of the array is known. We have this in our code for the day.

If we wanted to only print the value of one array position we would simple reference the position with square brackets, like below where we would reference the first value in an array:
```myList[0];```
<h2>Code For The Day</h2>
```
  1 public class TestArray {
  2    public static void main(String[] args) throws Exception {
  3        double[] myList = {1.0, 2.2, 3.2, 4.1 };
  4
  5         for(double element: myList) {
  6             System.out.println(element);
  7         }
  8     }
  9 }
```

Output
```
1.0
2.2
3.2
4.1
```

<h3>I'll be posting daily, sharing my experiences on my “1 Month of Java Code” experiences”, my previous post on day 17 can be found below, so feel free to have a look:
https://steemit.com/java/@run.vince.run/going-old-school-java-for-day-16</h3>

<h3>If you have found this post useful or interesting, please consider Commenting, Upvoting, Following and/or Resteeming</h3>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
post_id64,447,011
authorrun.vince.run
permlinkthis-is-the-read-day-18-of-javatober
categoryjava
json_metadata{"app":"steemit\/0.1","format":"markdown","links":["pexels.com","https:\/\/steemit.com\/java\/@run.vince.run\/going-old-school-java-for-day-16"],"tags":["java","coding","ilovecoding","teamaustralia","programming"],"image":["https:\/\/cdn.steemitimages.com\/DQmfYPyF6xkcXGZrZGNvNEyBHuBWRjEpjj7W7bPHeYuAMEJ\/background-code-coder-177598.jpg"]}
created2018-10-18 01:31:06
last_update2018-10-18 01:31:06
depth0
children2
net_rshares1,167,346,197,955
last_payout2018-10-25 01:31:06
cashout_time1969-12-31 23:59:59
total_payout_value1.077 SBD
curator_payout_value0.286 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length2,723
author_reputation13,081,774,742,601
root_title"This Is The Read Day 18 of Javatober"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (52)
@ilovecoding ·
Hello! Your post has been resteemed and upvoted by @ilovecoding because **we love coding**! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On! 
 ![](https://codingforspeed.com/images/i-love-coding.jpg) 
*Reply !stop to disable the comment. Thanks!*
👍  ,
properties (23)
post_id64,447,016
authorilovecoding
permlink20181018t013117833z
categoryjava
json_metadata{"app":"ilovecoding","tags":["ilovecoding"]}
created2018-10-18 01:31:18
last_update2018-10-18 01:31:18
depth1
children0
net_rshares10,587,316,209
last_payout2018-10-25 01:31:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length323
author_reputation40,842,386,526
root_title"This Is The Read Day 18 of Javatober"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (2)
@minnowsupport ·
<p>Congratulations!  This post has been upvoted from the communal account, @minnowsupport, by run.vince.run from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows.  Please find us at the <a href="https://discord.gg/HYj4yvw"> Peace, Abundance, and Liberty Network (PALnet) Discord Channel</a>.  It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.</p> <p>If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=102530.639667%20VESTS">50SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=205303.639667%20VESTS">100SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=514303.639667%20VESTS">250SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=1025303.639667%20VESTS">500SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=2053030.639667%20VESTS">1000SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=10253030.639667%20VESTS">5000SP</a>. <br><strong>Be sure to leave at least 50SP undelegated on your account.</strong></p>
properties (22)
post_id64,448,730
authorminnowsupport
permlinkre-this-is-the-read-day-18-of-javatober-20181018t021247z
categoryjava
json_metadata{"app":"beem\/0.19.55"}
created2018-10-18 02:12:48
last_update2018-10-18 02:12:48
depth1
children0
net_rshares0
last_payout2018-10-25 02:12:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length1,696
author_reputation104,981,098,086,561
root_title"This Is The Read Day 18 of Javatober"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000