Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > JAVA Technologies
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 02-02-07, 11:49 AM   #1 (permalink)
Member
 
Join Date: Nov 2006
Posts: 56
Thanks: 13
Thanked 3 Times in 3 Posts
Thanks: 13
Thanked 3 Times in 3 Posts
Rep Power: 3 Shiva Shankar is on a distinguished road
final variables in method

Hi,

A method can have final and non-final variables in java.
1.Where these(final&non-final) variables are stored in JVM?
2.what is the life time of final variables of a method?
3.Can we access final variables of a method out side of that method, if so how? Give me example and detailed explanation.

Wating for your answers....
Shiva Shankar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-02-07, 03:30 PM   #2 (permalink)
Moderator
 
t_mohan's Avatar
 
Join Date: Apr 2006
Location: India
Posts: 636
Thanks: 57
Thanked 78 Times in 63 Posts
Thanks: 57
Thanked 78 Times in 63 Posts
Rep Power: 17 t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold
Re: final variables in method

Hi shankar,

1A) In JVM Memory itself (in the HEAP)
2A) Method scope, if the method call or execution is finished then final variable is dead
3A) No you cannot, after all it is also a variable but which cannot be modified. we cannot access a local variable of a method from outside the method.

please find the example given below

publicclass FinalVariablesTest {
publicfinalint FINAL_INT=100;

publicvoid FinalVariableMethod()
{
finalint FINAL_INT1 =200;
System.out.println(
"Final Variable in Method:"+FINAL_INT1);

}
publicstaticvoid main(String[] args) {

FinalVariablesTest fvt =
new FinalVariablesTest();
System.out.println(
"Final Variable of Class:"+fvt.FINAL_INT);
fvt.FinalVariableMethod();

}
}

Please let me know your questions

Thank You
__________________
M0h@n

Last edited by t_mohan; 05-02-07 at 03:37 PM.
t_mohan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 14-02-07, 03:39 PM   #3 (permalink)
Banned
 
Join Date: Oct 2006
Location: India
Age: 25
Posts: 33
Thanks: 1
Thanked 4 Times in 4 Posts
Thanks: 1
Thanked 4 Times in 4 Posts
Rep Power: 0 hemanthjava is on a distinguished road
Re: final variables in method

Thanks for the info
hemanthjava is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can we declare variables inside a method as Final Variables preethisingh Java Interview / Technical Questions 1 02-02-07 11:54 AM
J2EE - What is final method? preethisingh Java Interview / Technical Questions 1 23-01-07 08:29 PM
J2EE - Can you make a method final, without making the whole class final? preethisingh Java Interview / Technical Questions 1 23-01-07 03:17 PM
java JSP naga JAVA Technologies 4 21-08-06 05:03 PM
JAVA PART3 naga JAVA Technologies 0 18-02-06 07:48 AM


All times are GMT +6.5. The time now is 02:41 PM.





Search Engine Optimization by vBSEO 3.1.0