Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 26th, 2012  |  syntax: None  |  size: 0.51 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. 'if' and 'for' loop questions
  2. public char[] methodA()
  3. {
  4.   char[] alphas = {'s', 't', 'e', 'a', 'm'};
  5.   char temp = alphas[0];
  6.   int i = 0;
  7.   while (i < alphas.length - 1)//1
  8.   {
  9.     alphas[i] = alphas[i+1]; //2
  10.     i++;
  11.   }
  12.   alphas[alphas.length-1]=temp;
  13.   return alphas;
  14. }
  15. public char methodB()
  16. {
  17.   char [] alphas = {'s','a','u','s','a','g','e'};
  18.   char first = alphas[0];
  19.   for (int i= 1; i < alphas.length; i++) //3
  20.   {
  21.     if (alphas[i] < first) //4
  22.     {
  23.       first = alphas[i];
  24.     }
  25.   }
  26.   return first;
  27. }