I am trying to write some code to print out a square made up of ‘*’s. The problem is that I get an error saying ‘.class expected’ after the variable ‘int stars’. I’m not sure what this means.
class Main
{
public static void main( String args[] )
{
int sqaure = 5;
int line = 1;
while ( line <= sqaure )
int stars = 1;
while ( stars <= square )
{
System.out.print( "*" );
stars = stars + 1;
}
System.out.println();
line = line + 1;
}
}
You changed your question to a completely different one. This is not really how SO works since the answers that were already here are not answers to your current question anymore.
Now you have a typo in the variable names (
sqaurevssquare).Please use an IDE as it will help you prevent these pesky little errors and can help you learn programming in java.