What is an inline method and when do we do that Regards, aakash
Joined: Jul 02, 2001
Hiya! What is an inline method and when do we do that? If I'm not completelty mistaken, inlining is a thing that's happening during compile-time. The compiler inserts the code for a method where the method itself is called. I think that this only happens when the called method is in the same class as the caller-method. I'll try to make an example. Consider this class:
Now this would be transformed to something like this during compile-time:
Not sure that it will be exactly this way, but the basiscs are ther I think. Hope this helps. /Peter
Joined: Mar 11, 2002
Peter's explantion on inline method is correct. But however, a method MAY be made inline if it is declared final. I don't thing all the final methods will be made inline. It is upto the compiler to decide to make a final method inline or not. Inline methods reduces the overheads on method calls.