Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Java code problem

  Asked By: Howard    Date: Jul 11    Category: Java    Views: 747
  

It says illegal start of expression and ponits an arrow to the } at
the end of for(int j = o......) }


import java.io.*;
import javagently.*;

class Rectangle {

int width;
int height;

/** Creates new Rectangle */
Rectangle(int argWidth, int argTall) {
width = argWidth;
height = argTall;
}

/** Display's a rectangle */
void show Rectangle(int argWide, int argTall) {
for(int i = 0; i < argWide; i++) {
System.out.print("*");
{
System.out.print("\n");
for(int i = 0; i < (argTall - 2); i++) {
System.out.print("*")
for(int j = 0; j < (argWide - 2); j++) {
System.out.print(" ");
}
System.out.println("*");
}

public static void main(String [] args)
Rectangle aRect = new Rectangle(4,4);
aRect.show();
}
}




Share: 

 

4 Answers Found

 
Answer #1    Answered By: Leon Evans     Answered On: Jul 11

At first sight I found missing semicolumn and brace:

/** Display's a rectangle */
void show  Rectangle(int argWide, int  argTall) {
for(int i = 0; i < argWide; i++) {
System.out.print("*");
{
System.out.print("\n");
for(int i = 0; i < (argTall - 2); i++) {
--> System.out.print("*");
--> }
for(int j = 0; j < (argWide - 2); j++) {
System.out.print(" ");
}
System.out.println("*");
}

 
Answer #2    Answered By: Garai Chalthoum     Answered On: Jul 11

i cant understand this
if this is a method , r u calling it from someother
class

/** Display's a rectangle */
void show  Rectangle(int argWide, int  argTall) {

ok , and another thing is , u cant use the same
variable inside another block , like u have used the
variable 'i' inside the block.

u must get an error like this

i is already defined in main(java.lang.String[])
for(int i =0;i<2;i++)
^
1 error

 
Answer #3    Answered By: Caitlin Brown     Answered On: Jul 11

semi colon is missing on the top of for loop j;

 
Answer #4    Answered By: Mamie Wallace     Answered On: Jul 11

Header of the show() method is not correct.

 
Didn't find what you were looking for? Find more on Java code problem Or get search suggestion and latest updates.




Tagged: