• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt in final method

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I heard that whenever final method is called subsequent code is subsitute to the method call?

Now i want to know whether it is for all cases R it may be decide by compiler
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
clarify your question.
I seriously doubt my mental capabilities to make sense of your choice of words (and that despite knowing 3 languages fluently and 3 more to some extent).
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Jeroen Wenting

Atleast can u get me now???

I heard that whenever final method is called,the corresponding code is subsituted to the method call?

Now i want to know whether it is applicable in all final method calls or its upto compiler to decide upon in some situation to substitute and in some not.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vidya is asking about inlining, inserting the bytecode for a method where the method is called.

There is no requirement that a compiler ever inline code, but making a method final, private, or static eliminates run-time dispatching (polymorphism) so inlining is easier. Java Hotspot is so aggressive in inlining that it will even deal with possible polymorphism.

My (pre-Java) textbook says that the main considerations are the size of the method and the scope of references. Sun has some nice discussions of inlining on their web site. Just search on "inlining".

Second Comment:

I had no problem understanding Vidya's question. If you don't understand a question, please ask for clarification or just don't answer. It's even possible that it's you who don't understand. There is no reason to insult someone who is doing his best.
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,

Originally posted by Mike Gershman:
Second Comment:

I had no problem understanding Vidya's question. If you don't understand a question, please ask for clarification or just don't answer. It's even possible that it's you who don't understand. There is no reason to insult someone who is doing his best.



I'm honestly impressed with you being able to understand what Vidya was asking. Hopefully, your explanation is what he was looking/asking for.

I don't think Jeroen was actually being rude or insulting. As we all know, this being the internet, people from all over the world can access this forum. Some folks may not have the luxury to read visually & relies on software to do the translation of posted messages into verbal messages. Hence, it is for the benefit of everyone that we could, perhaps, try to write our queries and replies in simple, clear & easily understood English.

Of course not everyone would be able to write in perfect English, but if we make an effort to, it would make our questions more easily understood by many others & hence increases the chances of us getting replies. At the same time, we get to improve on our English writing capability.

I'm not implying or suggesting that I could write well. In fact, I think my writing skills have rooms for further improvement. :roll:

Actually Vidya's second post was much clearer. Although I don't have the answer to his query, I could at least understand what he was asking.

Ultimately, we're all here to learn & share knowledge from one another.
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok friends

I will take it easy,whenever i am going wrong. UR best friends to correct me for my benefit.

If anyone tell answer for my question then i will be very happy
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chengwei:

Your English is very understandable, you must have really worked at it.

You should know that "hence" is not used much these days. Try using "so". "so it increases the chances ..." "So it is for the benefit of everyone ..."

Vidya:

What you asked about is called "inlining". Read my post above, search the Sun web site, google it, and please come back if you have more questions.
 
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vidya sagar:
I heard that whenever final method is called subsequent code is subsitute to the method call?

Now i want to know whether it is for all cases R it may be decide by compiler



Even now all guys in forum where discussing some thing other than java ....
Let me know ur doubt n specific....
So i will try to clrify ....
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vidya sagar:
I heard that whenever final method is called subsequent code is subsitute to the method call?

Now i want to know whether it is for all cases R it may be decide by compiler


say for Ex...

public class Final1
{
public final void mtd1()
{
System.out.println(" opps in final mtd");
}

public void mtd2()
{
System.out.println("i am from second");
}



public static void main(String l[])
{
Final1 o = new Final1();
o.mtd1();
}
}

o/p is opps in final mtd

did u menat to say that alll data in 2nd will print.... AS per Ur msg..
Let me know if my way of thinking is Wrong
[ April 13, 2005: Message edited by: Gowtham Ganamukala ]
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most non-native English speakers that I know enjoy blatancy when you point out their mistakes. This means that they can learn something.
If they get defensive, then that's their problem.
Blatancy != offensive (despite some western cultures suggesting so by means of inflated egos).

<two-cents currency="AU"/>
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic