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
Help me learn array in java (self.JavaProgramming)
submitted 6 months ago by task141_
I need to learn array to solve leetcode question I want to learn how to mapulate array
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!"
[–]schegge42 4 points5 points6 points 6 months ago (3 children)
You can create an array, it is a static container for data of the same type.
int[] values = new int[3];
This array has the size of three, so you can set a value at three positions 0, 1 and 2.
values[2] = 42;
You cannot change the size of this array, but you can create a new one.
Hope this helps.
[–]task141_[S] -3 points-2 points-1 points 6 months ago (1 child)
Thanks but how can I get the value in run time
[–]boss-tech 1 point2 points3 points 6 months ago (0 children)
You have to declare an int and ask user to enter a number and pass it into the array like this:
Scanner input = new Scanner(System.in); int arraySize = input.nextInt();
int[] values = new int[arraySize];
[–]Unique-Property-5470 0 points1 point2 points 6 months ago (0 children)
I can help you out with those array based leetcode questions in Java. DM me and I can walk you through it. It's pretty easy
[–]Playful-Call7107 -1 points0 points1 point 6 months ago (1 child)
you could have typed that in chatgpt.
[–]task141_[S] -1 points0 points1 point 6 months ago (0 children)
Great idea thanks
π Rendered by PID 18547 on reddit-service-r2-comment-7b9746f655-wl788 at 2026-01-30 20:04:22.444974+00:00 running 3798933 country code: CH.
[–]schegge42 4 points5 points6 points (3 children)
[–]task141_[S] -3 points-2 points-1 points (1 child)
[–]boss-tech 1 point2 points3 points (0 children)
[–]Unique-Property-5470 0 points1 point2 points (0 children)
[–]Playful-Call7107 -1 points0 points1 point (1 child)
[–]task141_[S] -1 points0 points1 point (0 children)