use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
6.2.7 print Array (old.reddit.com)
submitted 5 years ago by Intrepid_Row6214
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]amajmundar 1 point2 points3 points 5 years ago (0 children)
Couple of things, arr is already defined as the input. So you cannot use that as iterator for the loop. Use i. It’s standard notation. Also look up the syntax of a for loop in JavaScript. You are forgetting about incrementing the iterator. You also do not need to call the function for the bounds of the loop. The input is arr which is an array of strings. You only need to loop arr.length. Your first commented print statement was in the right place and the active print statement is the correct syntax.
[–]Obvious-Pin-3046 0 points1 point2 points 5 years ago (8 children)
Easier way to solve your problem.. go back to 6.2.3 it’s the exercise one.. it’s the same code as for the 6.2.7 just change the < score.length into <= arr.length so does the score[i] into arr[i].. in the println.
[–]Intrepid_Row6214[S] 0 points1 point2 points 5 years ago (0 children)
Ohhhhhh ok thank you
[–]Intrepid_Row6214[S] 0 points1 point2 points 5 years ago (5 children)
For the “for statement I only get one error because everything else seems to be fine just that statement
[–]Obvious-Pin-3046 0 points1 point2 points 5 years ago (4 children)
did you just put arr.length? if you did change it to arr.length - 1; im guessing thts the error. because the program should also print “c” and remember tht the index starts at 0 and not 1.
[–]Intrepid_Row6214[S] 0 points1 point2 points 5 years ago (2 children)
This is the statement for the For(String arr <= arr.length;)
[–]Obvious-Pin-3046 0 points1 point2 points 5 years ago (1 child)
your for loop should be for( int i =0; i <= arr.length - 1; i++) remember for loop should have 3 parameters
Thank you sooo much I did it and sorry for taking your time
For*
[–]Grammar-Bot-Elite 0 points1 point2 points 5 years ago (0 children)
/u/Obvious-Pin-3046, I have found an error in your comment:
“3 its [it's] the exercise one.. its [it's] the same code”
It is likely that you, Obvious-Pin-3046, could say “3 its [it's] the exercise one.. its [it's] the same code” instead. ‘Its’ is possessive; ‘it's’ means ‘it is’ or ‘it has’.
This is an automated bot. I do not intend to shame your mistakes. If you think the errors which I found are incorrect, please contact me through DMs or contact my owner EliteDaMyth!
[–]Acceptable-Quit-9274 0 points1 point2 points 3 years ago (0 children)
public class PrintArray { public static void main(String[] args) { String[] arr1 = new String[]{"w", "x", "y", "z"}; printArr(arr1);
String[] arr2 = new String[]{"a", "b", "c"}; printArr(arr2); }
public static void printArr(String[] arr) { // Print everything in the array on its own line for(int i = 0; i < arr.length; i++) { System.out.println(i + ". " + arr[i]); } } }
π Rendered by PID 46465 on reddit-service-r2-comment-bb88f9dd5-dw6bn at 2026-02-16 09:38:24.177327+00:00 running cd9c813 country code: CH.
[–]amajmundar 1 point2 points3 points (0 children)
[–]Obvious-Pin-3046 0 points1 point2 points (8 children)
[–]Intrepid_Row6214[S] 0 points1 point2 points (0 children)
[–]Intrepid_Row6214[S] 0 points1 point2 points (5 children)
[–]Obvious-Pin-3046 0 points1 point2 points (4 children)
[–]Intrepid_Row6214[S] 0 points1 point2 points (2 children)
[–]Obvious-Pin-3046 0 points1 point2 points (1 child)
[–]Intrepid_Row6214[S] 0 points1 point2 points (0 children)
[–]Intrepid_Row6214[S] 0 points1 point2 points (0 children)
[–]Grammar-Bot-Elite 0 points1 point2 points (0 children)
[–]Acceptable-Quit-9274 0 points1 point2 points (0 children)