Lonely arrays interact

  • 5
  • Locked
Let's create not one, but two arrays at the same time! One will be a refuge for 10 numbers, while the other will be a haven for 10 strings. Use the keyboard to populate an array of strings. In each element of the number array, record the length of the string whose string array index coincides with the current index of the number array. Then display the contents of the number array on the screen, and you're done.
You can't complete this task, because you're not signed in.
Comments (10)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Ice_ Beam
Level 7 , Germany
25 June 2021, 18:33
nice I solved this with inputs, 1 for loop and for each loop! I guess everyone has their code preference style!
OBINNA
Level 16 , Texas, United States
6 May 2021, 18:45
stuck a lil on this one found out array.length - length of an array n.length() - length of a string n. nice
Rebekah H
Level 8 , Gothenburg, Sweden
23 July 2020, 00:00
what is the output suppose to look like on this task?
Roman
Level 41
24 July 2020, 06:00
For example input : grandfather grandmother father mother son daughter cat dog program car Output : 11 11 6 6 3 8 3 3 7 3 because : the length of the string "grandfather" is 11 the length of the string "grandmother" is 11 the length of the string "father" is 6 the length of the string "mother" is 6 the length of the string "son" is 3 the length of the string "daughter" is 8 the length of the string "cat" is 3 the length of the string "dog" is 3 the length of the string "program" is 7 the length of the string "car" is 3
Rebekah H
Level 8 , Gothenburg, Sweden
26 July 2020, 02:52
thank you :)
Ice_ Beam
Level 7 , Germany
25 June 2021, 18:33
this helped a lot thanks!
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
2 November 2019, 00:04
I failed the last requirement of displaying the string lengths using this technique: System.out.println(Arrays.toString(listReference)); which outputs: [1, 2, 3, 4, 5, 4, 3, 2, 1, 1] or whatever the string lengths are I suppose they maybe want each length on a new line, so I will try that using println
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
2 November 2019, 00:14
that worked
Tonatiuh
Level 12 , Mexico, Mexico
30 October 2019, 21:19
There is a little difference in how to get the length of one array and the length of one array's element:
String[] arrayString = new String[15];  // Create a string array called arrayString for 15 elements.
m = arrayString.length;         // m = 15 is the length of the string array.
n = arrayString[3].length();    // n is the length of the arrayString[3] element.
Kyle Chatman
Level 11 , Oakland, United States
21 May 2019, 17:14
Note the verification requires the string array size to be hard coded as "10". A variable with value ten works but is not accepted. They're fine with the int array size being given via variable.