I had this question in my homework:
Display the value of the seventh element of character array f.
I think I know the basic rules of integer arrays but I'm not sure they apply to character arrays. This is what I have:
public class CharArray
{
public static void main( String args[] )
{
char f[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g' };
System.out.printf( "%s%8s\n", "Index", "Value" );
for ( int counter = 0; counter = 6; counter++ )
System.out.printf( "%5d%8d\n", counter, f[ counter ] );
}
}
Apparently, this doesn't work. I get the following error:
CharArray.java:9: incompatible types
found : int
required: boolean
for ( int counter = 0; counter = 6; counter++ )
Am I to understand that I can't use a counter to go through the subsequent elements in a char array like you would with a regular int array? Or do I just simply have a typo somewhere?