CodeGym /Java Course /Java Syntax /Arrays in memory

Arrays in memory

Java Syntax
Level 7 , Lesson 2
Available

"Hi, Amigo. Let me show you how this all works in memory."

Arrays in memory - 1

"What is 345?"

"Just a random number, but it represents the address of a string that contains the word 'Rain'."

"It's a bit more complicated with arrays."

"155,166,177 – these numbers are also random. Do they represent the addresses of the strings to the right?"

"Yes. It's good that you were able to guess that on your own. Note that there is an additional object here – an array with 10 elements."

"That makes perfect sense. Thanks. Seeing truly is believing. Thank you, Rishi."

7
Task
New Java Syntax, level 7, lesson 2
Locked
Favorite dish
Rename the parameters of the printPersonInfo() method: - firstName to name; - lastName to surname; - favoriteDish to meal; without changing the program's functionality. Leave the variable names in the main() method unchanged.
7
Task
New Java Syntax, level 7, lesson 2
Locked
The Liverpool 4
The createCrew() method displays the positions and names of the crew members on a spacecraft. To avoid any confusion inside the method, change the names of the createCrew() method's parameters to match the names of the variables passed to the method: - name1 to navigator - name2 to pilot - name3 in
7
Task
New Java Syntax, level 7, lesson 2
Locked
Correct order
Let's write a utility for working with arrays. The main functionality is ready: the printArray() method displays all the elements of the array on the console. What is left for you is just a trifle: implement the reverseArray() method. It should reverse the order of the elements in the array. The met
7
Task
New Java Syntax, level 7, lesson 2
Locked
A method for all seasons
It would be nice to have one method for solving all sorts of problems. You have the opportunity to write one: Create 9 more universalMethod() methods. In total, there should be 10 of them. Think of the parameters they should have.
Comments (13)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Anonymous #10907411 Level 6, United States of America, United States
17 January 2022
When you think you know what you're doing then get confused the very next page. Spain without the 's'
Shashikant Sharma Level 8, Surat, India
19 August 2021
Things Started To Make Sense And Also Bit Confusing. 🙃
punkuotukas Level 7, Vilnius, Lithuania
22 December 2020
It only creates more confusion. Where do those numbers come from? If I indicate any of those numbers as an array index, will it print out "rain" or "in" or "spain" with println? Not helpful at all.
Banana Llama Level 8
20 July 2021
They explained it a bit too deep I would say. The 0-10 is the position in the array that the value is in. The random number inside is a reference to where the primitive or object is stored in the memory of the device.
Jonaskinny Level 25, Redondo Beach, United States
1 February 2022
The random number references are created and used by the system, you would not need to refer to them directly. Your variable (object or primitive) would have a pointer to these values, so you only need to keep track of your variables. It's like the SKU code on a product. You go get Ice Cream since Ice Cream is on your shopping list. The Ice Cream has a SKU number on it that the store's system uses to track purchases, prices and inventory re-ordering etc. You just need to hang onto your shopping list until you get the Ice Cream, then just hang onto the Ice Cream.
Chandan Thapa Level 22, Dubai, United Arab Emirates
10 October 2020
Amazing.. diagrams help us relate to the examples much better.
BlueJavaBanana Level 37
11 April 2020
Can anyone help clarify? 1. Reference variable points to arrays base index s[0] 2. Each element in the array is also a reference variable that points to the object we wish to "store" in the array. I assume that if the array is storing primitive data types then the array simply stores the data, not a reference variable to the data.
Seb Level 41, Crefeld, Germany
20 May 2020
That's correct. :-)
Cristian Level 16, Bucharest, Romania
30 October 2019
Fain!
Renat Mukhametshin Level 16, Pervouralsk, Russain Federation
11 April 2019
very good and understood
Janusz Level 11, Radomsko, Poland
29 November 2018
I think so
Arko Sarkar Level 8, Mumbai, India
30 August 2018
Just to understand it clearly, in first example where it says String s = "Mama". 's' is the reference variable pointing to the object value "Mama" and this address is stored in the reference variable. Is this explanation correct?
// Java Poser Level 18, Cincinnati, United States
21 February 2019
"Just a random number, but it represents the address of a string that contains the word 'Rain'."