Trying my luck here. I know im stupid but I dont understand it. What does pic related mean?

Trying my luck here. I know im stupid but I dont understand it. What does pic related mean?

Attached: Screenshot_20190201-082201_1.png (710x279, 28K)

It returns the minimum value from an array of integers

Could you be a bit specific? Like what does each line do

kek

NYPT

For fucks sake im trying to safe my class here

No, it's self explanatory if you knew the basics of literally any programming language

Attached: 1548763078703.png (1000x432, 165K)

Sorry but you're going to fail middleschool IT, try not being a brainlet next time.

it means nothing, it doesn't work thus who cares what author tried to do.

I dont. Thats why im asking but my fault to expect anything from Jow Forums. Whatever thanks to that guy who helped me

Literally read it
If you got past grade 5 algebra you'll be able to derive enough from first principles of probable syntax in order to determine what each line does.

int m = a[0] means that m is the first value of the array, and int i =1 is the counter.
the while loop goes through all elements of the array.
The if condition says that if i'th value of the array is smaller than m, then m would be that i'th element of the array.
This goes on untill the last value of the array.

could you dumb it down just a bit more for me?

>the ABSOLUTE STATE of Jow Forums

Attached: 1545257799343.png (672x787, 930K)

Please leave this site immediately

OP, that pic is bad bad news don't ever try to compile that code.

Which part are you confused by, goyim?

you have "public"(accessible for everyone), "static"(you don't have to define the object to use that method(function(small separated piece of code) tied to the class))) method(explained) which returns int(defines maximum size variable(temporary piece of stuff that holds changable data) can hold) and accepts array(many types(abstract notion of thing) one after the other) of int.
Now you define a variable m to be zeroth element of array a which you supplied in the arguments.
Now you define(assign the type and sometimes value to variable) a variable i which is 1.
This is gonna get hard now.
Imagine that that stuff between brackets will repeat until (i !=(means not equal) a.lenght(call to the method of a)) is no longer true, it will check it after every repetition. This is what `while` means.
Another hard word, if means that `m = a[i]` will only execute if a[i] is smaller than m. Why? because you want smallest number in array
Now you add 1 to i by taking current value of i and adding 1 to it then saving it to i again.
After all that revolving, you return m which should hold value of lowest number in your array of ints

F I Z Z B U Z Z

This

Thanks guys, really appreciate it

Retardo, "a" is the name of a list of numbers provided elsewhere. The number in the square parentheses is the position of each number on the list, starting at 0 and counting up. You can refer to each number on the list by the name of the list and its position in it.
The first line established the type of the function, saying its name (min), what type of input it receives (a list of numbers to be referred to as "a") and the type of output it returns (an integer, a full number). After this line you can assume a[] is a given.
2nd and 3rd lines define two variables of the integer type: m being the retainer of the currently-smallest-found-number, and i being a counter, a number that gets incremented during loops.
4th line is a "while" loop. As long as the condition in the parentheses is met, the instructions within the following {} brackets will be performed over and over again. In this code, the condition is "i is different from the length of the list a".
While that condition is met, line 5 as whether or not the number at position i is smaller than m. If so, m receives the value of that number, keeping m the currently-smallest-found-number.
Regardless of this condition, line 6 increments i.
This loop increases i with each go and thusly compares m against all numbers in the list a. At the last go i is incremented and is equal to the length of the list. Since many languages start counting at 0, there is no longer a number in a[a.length]. The numbers end one position prior to that. Since i is equal to this number, that means all numbers were checked, and the condition of inequality is not met. We move on to line 8, where the value stored in m is returned to wherever the function was/will be called from.

This shit is super basic, dude. If recommend picking up a programming book or watch tutorials on YouTube. This is like the absolute basis of algorithms and is about the first example of loops.

i dont understand.

why does it return the minimum of the array?

Goyim is plural. It doesn't make grammatical sense using it. Goy is the singular, but since we're on a primarily English speaking image board, I'd just recommend you use the English word for it: gentile.

because every time it encounters something less than m it makes m equal that

>using the wrong curly bracket convention
destined to fail

Really? It's a common word on my main board.

debug the program lad
suppose you have an array v = {3,4,1,2}
m = v[0] = 3
is v[1] < m?—> (4 < 3)? no —> don’t do anything
is v[2] < m?—> (1 < 3)? yes —> do m = v[2] = 1
is v[3] < m?—> (2 < 1)? no —> don’t do anything
now m contains the lowest value in the array v

That's a segfault waiting to happen.

*passes an uninitialized array to your function*
pssh nothin personnel kid

Say you and 3 of your hypothetical friends wish to find out who is the poorest. You call your not-existing father for assistance. All you 4 are standing in line, and your father walks up to each one. Say you are first, your dad asks you how much money you got in your balance. You say 100 dollars. Since your dad has no idea how much money any of you have, he assumes you're the poorest and remembered the number 100. He then walks up to friend #1 behind you and ask him how much money is in his balance. Friend #1 says 60 dollars. Your dad realized you aren't the poorest one and now, finding a poorer one, remembers the number 60. He walks up to friend #2 who answers he's got 230 dollars. Your dad understands #2 is not the poorest and moves on, remembering the number 60 still. Friend #3 says -50 dollars as he's in debt, your dad finds it to be the poorest and now remembers -50.
Reaching the end of the line, your absent father exclaims "the poorest person among you has -50 dollars."

But where did v come from? Werent we using a?

>a.length
how to specify the length of an array in a method? should I add another parameter indicating its length or is there another way?

Your main board is probably filled with buzzword-repeating dumbasses who don't know half the words they're quoting. It's time for you to transcend the mindless regurgitations and attempt to raise the quality of discussion in this board of yours as I do mine.

if a.length != 0:
fxn
else:
printf("nigga that shit empty");

min() is a method that takes “a” as a parameter, think of “a” as a place holder
you can call min(v) in your main program then v takes the place of a

this isn’t how it actually happens but it’s a simplified explanation

idk, OP
this is very bad code snippet, it has no comments
just ignore bad code like this

What are methods and parameter? You guys keep saying this is easy but now you're just throwing words at me

google is your friend

define easy

user, i am sad that you didn't take time to read my post. Here it is in case you need to renew your memory

Ill be damned.
Thanks goy.

This

Segfault in java?

I Concur

>public
I HEREBY OPEN THIS FACTORY FOR IMMEDIATE PUBLIC USE AND DECLARE IT COMMUNAL
>static
TO ALL ENTITIES REGARDLESS OF RACE, GENDER, KINSHIP, PRIOR EMPLOYMENT, OR CRIMINAL STATUS, KNOWN OR UNKNOWN, TRAINED OR UNTRAINED;
>int
IT SHALL PRODUCE UNDER ANY AND ALL CIRCUMSTANCES NOTHING BUT ONE WHOLE NUMBER,
>min
AND IT SHALL HENCEFORTH, AS WRITTEN ABOVE THE GATES, BE CALLED min.
>(
ANY AND ALL ENTITIES WISHING TO MAKE USE OF THIS FACTORY MUST PROVIDE
>int
WHOLE NUMBERS,
>a
HEREUNTO AND HENCEFORTH REFERRED TO AS a,
>[]
WHEREBY THEY SHALL BE ARRANGED IN A LIST.
>)
THIS SHALL BE THE ONE AND ONLY REQUIREMENT FOR THE UTILIZATION OF THIS BUILDING.
>{
I SHALL NOW BEGIN THE FULL AND CIRCUMENCOMPASSING DESCRIPTIONS OF SEVERAL AND ALL MACHINERY AND THEIR WORK STATIONS CONTAINED WITHIN THESE GATES, IN THE SEQUENCE UPON WHICH THEY SHALL BE UILIZED BY ANY AND ALL WORKERS WITHIN THESE WALLS.
>int
THERE IS CHALKBOARD ON WHICH A WORKER SHALL WRITE DOWN WHOLE NUMBERS AS INSTRUCTED
>m
AND IT IS OF A MAROONISH COLOR
> =
AND UPON IT A WORKER SHALL WRITE
> a
OF THE LIST a
>[
THE
>0
>VERY FIRST
>]
ELEMENT ON THAT LIST
>;
THEREUPON THE WORKER SHALL MOVE ON TO THE NEXT STATION:
>int
THERE IS CHALKBOARD ON WHICH A WORKER SHALL WRITE DOWN WHOLE NUMBERS AS INSTRUCTED
>m
AND IT IS OF AN INDIGOISH COLOR
> =
AND UPON IT A WORKER SHALL WRITE
> 1
THE NUMBER ONE
>;
THEREUPON THE WORKER SHALL MOVE ON TO THE NEXT STATION:
>while
WHICH COMPRISES SEVERAL WORK STATIONS WHICH SHALL BE EXECUTED IN SEQUENCE UNDER
>(
THE CONDITION THAT
>i
THE NUMBER ON THE INDIGO CHALKBOARD
>!
DOES NOT UNDER ANY CIRCUMSTANCE
>=
EQUATE TO
>a
THE LIST a
>.
'S
>length
LENGTH
>)
HAS BEEN MET.
>{
IF THE PRIOR CONDITION HAS BEEN MET, THE WORKER SHALL
>if
IF AND ONLY IF
>a
ON THE LIST a
>[
THE WHOLE NUMBER, STARTING FROM THE TOP, BEGINNING AT THE COUNT OF ZERO, ON THE POSITION
>i
WRITTEN ON THE INDIGO CHALKBOARD
>]
WRITTEN THEREUPON
>m
TO THE WHOLE NUMBER WRITTEN ON THE MAROON CHALKBOARD
>)
ONLY THEN

>let's set m to the first element of the array
>OH SHIT THE ARRAY DOESN'T HAVE ELEMENTS FUCK
This code sucks

Start reading "headfirst java", all your questions shall be answered there.

Tl;dr?

STOP SPOONFEEDING NOOBS

What about breastfeeding :e

>you would have used throw new error in Java

shame. tl;dr
There is that thing called class which holds data and methods. Methods are like functions which are specific only for this class. Functions are isolated pieces of code which should perform one thing well.
Parameters allow functions to change it behavior, they are those things between ()

It's essentially a function. In the best case, functions work like they do in math by that they take some kind of input (parameters, the x in "f(x)"), perform calculations on it and return a result.
However, since it's written in Java, a so called object-oriented programming language, everything has some kind of relation to an object (even though the "static" attribute means it's not related to any particular object, but rather a "class" of objects, or in this case, nothing at all). Methods are functions which are invoked in the context of an object (as an example, every Java object has a method called "toString" which takes no parameters and returns a textual representation of that object).

only if you have milk

what language is this

Cringe.

Poor bluepilled goyim.

fucking kek I can get behind this

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

lel this

> m
SHALL THE WORKER TAKE THE MAROON WHITEBOARD
> =
AND WRITE UPON IT, AFTER ERASING IT
>a
ON THE LIST a
>[
THE WHOLE NUMBER, STARTING FROM THE TOP, BEGINNING AT THE COUNT OF ZERO, ON THE POSITION
>i
WRITTEN ON THE INDIGO CHALKBOARD
>]
WRITTEN THEREUPON
>;
HOWEVER UNTOFORE ANY CIRCUMSTANCE THEN
>i
SHALL THE WORKER TAKE THE INDIGO CHALKBOARD
> =
AND WRITE UPON IT, AFTER ERASING IT
> i
THE NUMBER CURRENTLY WRITTEN ON THE INDIGO CHALKBOARD
> +
INCREMENTED BY
> 1
ONE
>;
THEN,
>}
THE WORKER SHALL RETURN TO THE WORKSTATION OF THE PREVIOUS OPEN BRACKET AND CONTINUE THE WORKFLOW DELINEATED THEREIN AS LONG AS THE PREREQUISITE CONDITION HAS BEEN MET, UNTIL SUCH A TIME AS THE PRESUPOSITION DOES NO LONGER HOLD, AT WHICH POINT THE WORKER SHALL CONTINUE FORWARD WITH THE FOLLOWING INSTRUCTION:
>return
THE WORKER SHALL OBTAIN ONE MEGAPHONE, ENGAGE IT, OPEN THE FACTORY DOORS, AND PROCLAIM TO THE INTERESTED PARTIES
>m
THE CONTENTS OF THE MAROON CHALKBOARD
>;
WITH PRIDE. AT THIS POINT, THE WORKER MAY GO HOME IF HE OR SHE SO CHOOSES.
>}
THIS CONCLUDES THE FULL AND CIRCUMENCOMPASSING DESCRIPTION OF SEVERAL AND ALL MACHINERY AND THEIR WORK STATIONS AND WORK FLOWS CONTAINED WITHIN THESE GATES AND THE SEQUENCE AND FASHION IN WHICH THEY SHALL BE UTILIZED WITHIN THESE WALLS.

public class Shit {

public static Integer min(int a[]) {
Integer m = (a.length == 0) ? null : a[0];
for (int i = 1; i < a.length; i++)
if (a[i] < m) m = a[i];
return m;
}

public static void main(String[] args) {
int a[] = {};
Integer m = min(a);
System.out.println(m);

int b[] = {3,1,2};
Integer n = min(b);
System.out.println(n);
}

}

>a.length
would't that output an error?

I knew 4channel still had some hope to it. Absolutely lovely.

>would't that output an error?
no, because a is an array and arrays always have a length property which is zero if array is empty

Have you considered writing a book on programming?

You ought to safe your own brain first

wait this isn't java
I talking about the case when the array isn't empty

no. if you get it illustrated and published, sure.
EN-US, a mixed level multipurpose language.

nevermind, I was using length() with a array

Can you dumb it down further I still dont get it :-(

I can't say for sure if this is a retard or a troll
Can a famalam give me some pointers?

...

>html is programming

cringe

>public static

It means you're using a retarded language.

that's a really confusing way to write a for loop

Pointers are too advanced, let's just stick with ints and chars for now.

I hope you've got a beard

Attached: programming for commies.png (1405x2297, 135K)

>tfw a.length == 0

Its like visiting Jow Forums knowing only english

thank you for making my day

It's just a round-about for loop. It sets the a temp variable to the first index of the array, then on each iteration checks to see if the current index is less than the temp variable. If so, it sets the temp variable to that value. Then, when it has finished iterating through the array, it returns the temp value, ie the smallest value in the array.

Seriously. This is remedial tier code. If you can't understand that you should probably switch to being an art major or something.

Glory to Arstotzka.

m stores what the program currently thinks is the minimum in the array. i is a counter that allows the program to know which element to access every loop iteration and terminate after it has been through all the arrays elements. The if statement stores the value the current element in the array in m if it's lower than what is currently in m.

YHBT

>YHBT
I think we know, however. The Explanations posted are f'ing golden.
This one is my favorite

what kind of awful shit language is that literally kill yourself no wonder you cant read it or understand its such a shit language
int imin(int *x, unsigned n){
int y = *x;
if(!(n>1)) goto ret;
unsigned m=0;
cmp:
y = *(x+(++m)) < y ? *(x+m) : y;
if (m==n-1) goto ret;
goto cmp;
ret:
return y;
}

Attached: laughs.jpg (240x210, 6K)

kek what the fuck

>goto ret

Attached: 07urk85p4ja11.jpg (432x767, 38K)

>nor using goto at every opportunity
what are you some sort of djikstraboi in his cuckshed?

It means that someone is allergic to for loops

I hate code that autistically catches exceptions that should be relayed to the caller