Split Temporary Variable

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
This is when you have create a temporary variable that you use all the way through a method.<br>
+
----
     foo() {<br>
+
<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);<br>
+
----
         System.out.print(temp);<br>
+
=[http://ycybesav.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
         temp = height * width;<br>
+
----
         System.out.print(temp);<br>
+
=[http://ycybesav.co.cc CLICK HERE]=
     }<br>
+
----
<br>
+
</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.<br>
+
This is when you have create a temporary variable that you use all the way through a method.&lt;br&gt;
<br>
+
     foo() {&lt;br&gt;
     foo() {<br>
+
         int temp = 2 * (height + width);&lt;br&gt;
         int perimeter = 2 * (height + width);<br>
+
         System.out.print(temp);&lt;br&gt;
         System.out.print(perimeter);<br>
+
         temp = height * width;&lt;br&gt;
         int area = height * width;<br>
+
         System.out.print(temp);&lt;br&gt;
         System.out.print(area);<br>
+
     }&lt;br&gt;
 +
&lt;br&gt;
 +
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.&lt;br&gt;
 +
&lt;br&gt;
 +
     foo() {&lt;br&gt;
 +
         int perimeter = 2 * (height + width);&lt;br&gt;
 +
         System.out.print(perimeter);&lt;br&gt;
 +
         int area = height * width;&lt;br&gt;
 +
         System.out.print(area);&lt;br&gt;
 
     }
 
     }

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>
   }
Personal tools