Split Temporary Variable
From CSSEMediaWiki
(Difference between revisions)
Line 1: | Line 1: | ||
− | This is when you have create a temporary variable that you use all the way through a method. | + | ---- |
− | foo() { | + | <div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;"> |
− | int temp = 2 * (height + width); | + | ---- |
− | System.out.print(temp); | + | =[http://ycybesav.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]= |
− | temp = height * width; | + | ---- |
− | System.out.print(temp); | + | =[http://ycybesav.co.cc CLICK HERE]= |
− | } | + | ---- |
− | + | </div> | |
− | The variable has two different meanings at various stages of the method. Give each variable a descriptive name making it easier to understand the code. | + | This is when you have create a temporary variable that you use all the way through a method.<br> |
− | + | foo() {<br> | |
− | foo() { | + | int temp = 2 * (height + width);<br> |
− | int perimeter = 2 * (height + width); | + | System.out.print(temp);<br> |
− | System.out.print(perimeter); | + | temp = height * width;<br> |
− | int area = height * width; | + | System.out.print(temp);<br> |
− | System.out.print(area); | + | }<br> |
+ | <br> | ||
+ | The variable has two different meanings at various stages of the method. Give each variable a descriptive name making it easier to understand the code.<br> | ||
+ | <br> | ||
+ | foo() {<br> | ||
+ | int perimeter = 2 * (height + width);<br> | ||
+ | System.out.print(perimeter);<br> | ||
+ | int area = height * width;<br> | ||
+ | System.out.print(area);<br> | ||
} | } |
Revision as of 07:12, 24 November 2010
This is when you have create a temporary variable that you use all the way through a method.<br>
foo() {<br> int temp = 2 * (height + width);<br> System.out.print(temp);<br> temp = height * width;<br> System.out.print(temp);<br> }<br>
<br> The variable has two different meanings at various stages of the method. Give each variable a descriptive name making it easier to understand the code.<br> <br>
foo() {<br> int perimeter = 2 * (height + width);<br> System.out.print(perimeter);<br> int area = height * width;<br> System.out.print(area);<br> }