Is there a way to get this down to one line of code?

boolean [] myArrary = {true, false};
return myArrary;

I'm trying to combine those lines into one, but I am not sure what the correct syntax would be.

Thanks, sj

Recommended Answers

All 3 Replies

Member Avatar for iamthwee

Care to elaborate.

the syntax you're looking for is:

return new boolean[] {true, false};

ahh thanks. I didn't have the "new" keyword

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.