<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>
post_id | 64,447,011 |
---|---|
author | run.vince.run |
permlink | this-is-the-read-day-18-of-javatober |
category | java |
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"]} |
created | 2018-10-18 01:31:06 |
last_update | 2018-10-18 01:31:06 |
depth | 0 |
children | 2 |
net_rshares | 1,167,346,197,955 |
last_payout | 2018-10-25 01:31:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.077 SBD |
curator_payout_value | 0.286 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 2,723 |
author_reputation | 13,081,774,742,601 |
root_title | "This Is The Read Day 18 of Javatober" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ausbitbank | 0 | 368,072,088,831 | 5% | ||
anarcist69 | 0 | 75,116,720 | 1.8% | ||
choogirl | 0 | 8,875,940,416 | 5% | ||
gamersclassified | 0 | 970,469,787 | 2.7% | ||
mikepedro | 0 | 606,150,330 | 9% | ||
gohba.handcrafts | 0 | 3,740,109,287 | 5% | ||
minnowsupport | 0 | 81,447,647,571 | 1.75% | ||
teamaustralia | 0 | 7,156,000,546 | 10% | ||
centerlink | 0 | 129,813,814,969 | 18% | ||
onethousandwords | 0 | 245,951,602 | 9% | ||
chrisdavidphoto | 0 | 513,697,862 | 1.35% | ||
revo | 0 | 15,106,172,623 | 18% | ||
webcoop | 0 | 415,779,653 | 9% | ||
masterwu | 0 | 163,384,894 | 5.4% | ||
plantstoplanks | 0 | 1,762,324,653 | 5% | ||
bobdos | 0 | 696,204,125 | 1.8% | ||
lordnigel | 0 | 1,105,245,712 | 6% | ||
cryptwo | 0 | 2,003,813,551 | 16.2% | ||
freemon | 0 | 70,929,085 | 8% | ||
aussieninja | 0 | 38,295,360,941 | 80% | ||
jordan.white306 | 0 | 203,693,250 | 9% | ||
bengy | 0 | 76,320,558 | 0.54% | ||
bec-on-the-block | 0 | 492,085,945 | 9% | ||
terrylovejoy | 0 | 2,738,339,071 | 9% | ||
gio6 | 0 | 72,822,811 | 9% | ||
benleemusic | 0 | 10,188,729,152 | 5% | ||
runningproject | 0 | 3,800,155,273 | 25% | ||
positiveninja | 0 | 2,071,513,668 | 9% | ||
evlachsblog | 0 | 839,312,725 | 9% | ||
sapphic | 0 | 1,752,870,700 | 9% | ||
run.vince.run | 0 | 10,431,619,044 | 100% | ||
bobaphet | 0 | 392,440,281 | 0.9% | ||
melbourneswest | 0 | 781,743,963 | 9% | ||
philippekiene | 0 | 189,659,171 | 5.4% | ||
cryptoslicex | 0 | 183,231,515 | 9% | ||
maujmasti | 0 | 642,316,603 | 100% | ||
lifeofryan | 0 | 94,396,985 | 9% | ||
primersion | 0 | 677,526,809 | 18.75% | ||
msp-active | 0 | 439,925,779,961 | 75% | ||
sue-stevenson | 0 | 481,843,366 | 7% | ||
niouton | 0 | 1,728,072,894 | 7.2% | ||
lifeobserver | 0 | 166,830,842 | 13% | ||
anzub | 0 | 18,511,078,184 | 75% | ||
byebyehamburgers | 0 | 2,962,566,137 | 80% | ||
apshamilton | 0 | 1,527,027,494 | 7% | ||
deividluchi | 0 | 279,417,841 | 9% | ||
metametheus | 0 | 835,195,094 | 5.94% | ||
torrey.blog | 0 | 562,771,724 | 12.5% | ||
bernardwest | 0 | 2,473,168,918 | 9% | ||
ilovecoding | 0 | 781,936,235 | 10% | ||
positiveninja2 | 0 | 117,531,960 | 4.5% | ||
steemitbuzz | 0 | 227,996,623 | 50% |
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!*
post_id | 64,447,016 |
---|---|
author | ilovecoding |
permlink | 20181018t013117833z |
category | java |
json_metadata | {"app":"ilovecoding","tags":["ilovecoding"]} |
created | 2018-10-18 01:31:18 |
last_update | 2018-10-18 01:31:18 |
depth | 1 |
children | 0 |
net_rshares | 10,587,316,209 |
last_payout | 2018-10-25 01:31:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 323 |
author_reputation | 40,842,386,526 |
root_title | "This Is The Read Day 18 of Javatober" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
run.vince.run | 0 | 10,222,171,474 | 100% | ||
ilovecoding | 0 | 365,144,735 | 5% |
<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=&delegatee=minnowsupport&vesting_shares=102530.639667%20VESTS">50SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=205303.639667%20VESTS">100SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=514303.639667%20VESTS">250SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=1025303.639667%20VESTS">500SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=2053030.639667%20VESTS">1000SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=10253030.639667%20VESTS">5000SP</a>. <br><strong>Be sure to leave at least 50SP undelegated on your account.</strong></p>
post_id | 64,448,730 |
---|---|
author | minnowsupport |
permlink | re-this-is-the-read-day-18-of-javatober-20181018t021247z |
category | java |
json_metadata | {"app":"beem\/0.19.55"} |
created | 2018-10-18 02:12:48 |
last_update | 2018-10-18 02:12:48 |
depth | 1 |
children | 0 |
net_rshares | 0 |
last_payout | 2018-10-25 02:12:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 1,696 |
author_reputation | 104,981,098,086,561 |
root_title | "This Is The Read Day 18 of Javatober" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |