Can someone explain to me this code
new Object[]{"PLease","Help"};
Ive never seen code like this before,
so It would be helpful if someone explains these to me.
Thank you in advance
You are creating a new Object array, that has 2 Strings in it, "PLease" and "Help".
The construct you are using is called an anonymous array, because you are not assigning the array to anything (useful if you want to pass the array to a method).
See http://docstore.mik.ua/orelly/java-ent/jnut/ch02_09.htm
It's short hand for a in-line array.
It's the same as doing...
Object[] aArray = new Object[2];
aArray[0] = "PLease";
aArray[1] = "Help";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With