Hi. I got a noobish question:

Is it possible to return an array "directly", so, something like this.

public int[] getArray(){

return int[]{this.intA, this.intB};

}

I know I can just make the array first. But does this not use unnecessary cpu time and memory? This is going to be used a lot, so performance is the most important element here.

Thanks:)

Is it possible to return an array "directly",

Have you tried it with the compiler? Do you get errors?

Yes. I can't seem to find a legal way of doing this.

sample code:

public int[] retInt() {
  return new int[}{1};
}

Ohh, yeah. Right ^^. Lol, I accually knew that when you mentioned it. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.