The Artima Developer Community
Sponsored Link

Java Answers Forum
Variables

2 replies on 1 page. Most recent reply: Mar 7, 2002 5:09 PM by Chad Daniels

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Tim

Posts: 5
Nickname: anna
Registered: Mar, 2002

Variables Posted: Mar 7, 2002 2:19 PM
Reply to this message Reply
Advertisement
Is it legal to declare a variable in one method which has the same name as a variable declared in another method? If this is so how are they related and if the value of one of these variables is changed what effect is apparent in the other variable?


Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: Variables Posted: Mar 7, 2002 3:40 PM
Reply to this message Reply
Yes. Local variables declared in different methods can have the same names. They are distinct variables and will not interfere with each other.

Chad Daniels

Posts: 2
Nickname: chad
Registered: Mar, 2002

Re: Variables Posted: Mar 7, 2002 5:09 PM
Reply to this message Reply
It is legal to declare two variables with the same name if they are in two different methods. Each one occupies its own spot in memory and is directly associated with the method in which it was created. Remember that that a variable lives and dies within the curly braces of its parent method. Changing the value of one does not affect the value of the other.

Flat View: This topic has 2 replies on 1 page
Topic: javadocs for com.ibm.websphere.csi.* Previous Topic   Next Topic Topic: converting vector to array

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use