Your problem isn't with the "return", it's with the earlier declaration of variable "a" and the declaration of the method. In both cases, you declared it as "int", but it is [a reference to] an array, so should have been declared "int".
Once your method and your variable "a" are declared as "int", you can just use "return a" to return [a reference to] the array.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Apr 07, 2007
when i tried to compile the following program, i got an incompatible type error ... (for returning an array) ....
You've hit upon a very, very important idea in Java, and in OO languages in general. It's useful to think of the methods you create for your objects as message senders and receivers. As you get deeper and deeper into the language you'll see that a method's "signature" (in other words the messages it must receive and the message it returns) are always a crucial part of understanding the method itself - in many cases the ONLY thing you'll know about how a method works is what you must send to it, and what it will return to you. So, you're on the right track figuring out how to return an array!
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)