#Simple Array related question (giving an method that requires an Array and array )

16 messages · Page 1 of 1 (latest)

gilded vale
#

well i dont really understand why i cant give the CreateGUI method the component Array my Array as i understand would work, maybe i am just making a simple mistake

oblique rainBOT
#

<@&987246487241105418> please have a look, thanks.

fiery flint
#

{components} that is invalid syntax

gilded vale
#

i mean just like in an example like that this would work

fiery flint
#

you need to do new Component[] {component}

gilded vale
#

hmm, i mean i think in the past i did something like that in the past, (that time must have been with numbers, wich should not really change anything)

#

ohhhhh

#

now i get it

#

thanks 😭

#

yeaaah that looks more like it

fiery flint
#

int[] a = {1,2,3,4} is just syntactical sugar for int[] a = new int[] {1,2,3,4}

#

an array in java is always an heap object. but you also can not create arrays with {}

#

that is special syntax for defining on the right hand side of an declaration with definition

#

just a free {1,2,3,4} does not create an object it is invalid syntax

#

so you can only use= {...} when you declare the array

gilded vale
#

ye its almost self answering, you gotta tell the method first you want to give it an array as i would understand, still learning, i mean that project is something new again, to learn more, firstly to learn about http requests with java, and always writing something new, to write better and simpler code