Can someone explain this code to me
new Object[]{"PLease","Help"};
I've never seen such code before,so it would be helpful if someone explained this to me. Thank you in advance
This is a short hand for an inline array.
This is the same as doing ...
Object[] aArray = new Object[2]; aArray[0] = "PLease"; aArray[1] = "Help";
You create a new array of objects in which there are two lines in it: "PLease" and "Help".
The construct used is called an anonymous array because you do not assign the array to anything (useful if you want to pass an array to a method).
See http://docstore.mik.ua/orelly/java-ent/jnut/ch02_09.htm
It:
new Object [] {"PLease", "Help"};
It is equivalent to:
Object[] array = new Object[size]; array[0] = "PLease"; array[1] = "Help";
Hope this clears up a bit.