java - Am I referencing this array position wrong? -


hi writing method larger program keep getting error symbol cannot found. please help!

 public static int maxinc (char []ch)  {   int current = 1;   int max = 1;    if (ch.length == 0)   {      return 0;   }   else if (ch.length == 1)   {      return 1;   }   else   {      (int = 1; < ch.length; i++);      {         if(ch[i] >= ch[i-1]) //the error @ ch[i] , ch[i-1]         {            current++;            if(current > max)               max = current;            else                current = 1;            }      }       return max;   }             } 

there semi colon in line :

for (int = 1; < ch.length; i++); 

remove , make line below:

for (int = 1; < ch.length; i++) 

while there semicolon happening loop happen while nothing done. became statement. below code happening second example:

this sample code

for (int = 1; < ch.length; i++); {      if(ch[i] >= ch[i-1])       {           current++;           if(current > max)               max = current;           else                current = 1;           } }  

will work this

for (int = 1; < ch.length; i++) {       //nothing happening }  // give error declaration in above loop if(ch[i] >= ch[i-1]) {      current++;      if(current > max)         max = current;       else          current = 1;     } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -