It's not a secret anymore!*
The moose likes Java in General and the fly likes Inline function in JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Inline function in JAVA" Watch "Inline function in JAVA" New topic
Author

Inline function in JAVA

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

Hi .... Is there any option in java from where I can use the funcionality like of inline function as I used in c++?


No Kaustubh No Fun, Know Kaustubh Know Fun..
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

In Java, there is no way to specify that you want a method to be inlined.

However, the JVM does inlining automatically for you. If you have for example a JavaBean class with simple getters, like this:

then the JVM will be smart enough to inline those getter methods at the places you call them. So calling those getter methods will be just as efficient as accessing the member variables directly.

In other words, normally you don't have to worry about inlining yourself in Java.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Inline function in JAVA
 
Similar Threads
final modifier
jQuery newbie doubts
JSP + javasscript
Ever Need Hand Optimized Byte Code?
How do I include a java method in a section of jsp code