title: smallest and largest in java. else if?
body: <p>i had to make a program that told you the largest and smallest number of 5 numbers and i keep getting smallest = 0 and largest = 0 on output. i havent added comments or anything like that yet, and ive tried else if and it isent working at all(surprised i got else working). Can someone please help me with this one. I shouldn't need help with this but i just cant figure this out.</p>
  
  <pre><code>public class int_big_small {
      public static void main(String args[]){
  
          int num1=3, num2=9, num3=5, num4 = 3, num5 = 7;
          int largest = 0, smallest = 0;
  
              if(num1 &gt; num2){
                  num1 = largest;
                  num2 =  smallest;
              }else{
                  num2 = largest;
                  num1 = smallest;
              }
  
              if(num3&gt;largest){
                  num3 = largest;
              }
              if(num3&lt;smallest)
                  num3 = smallest;
              if(num4&gt;largest){
                  num4 = largest;
              }
              if(num4&lt;smallest)
                  num4 = smallest;
  
              if(num5&gt;largest){
                      num5 = largest;
                  }
                  if(num5&lt;smallest)
                      num5 = smallest;
  
  
  
              System.out.println("the smallest number is " + smallest + " and the largest is " + largest);
      }
  }
  </code></pre>