• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error message: illegal start of type  RSS feed

 
Bob Matthews
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

my code:-

for (int i = 0;i < 4;i++) {
some code here .........
}

error message:-

illegal start of type

cannot find symbol
symbol: class j
location: AAA (name of program)

<identifier expected>

Unsure what is wrong here?

Bob M
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, UseCodeTags.

The compiler can't find a class named j you are trying to use.
Unfortunately you didn't show us the code that uses j.
 
Bob Matthews
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry..............

 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should not be calling classes things like j or AAA.
It is possible that j is in such a position that the compiler thinks it is a class name, but you have got it out of position and it is not supposed to be a class name.
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, take a look at line 3. Do you see an error there?
 
Bob Matthews
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell

You have hit the nail on the head...................

I wish j to be an integer - not a class name

What do I do to stop the compiler thinking it is a class name ?

and yes..... I missed an "=" in line 3

I used "AAA" for simplicity - it represents the name of the java program

Bob M
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see anything wrong in your code regarding the identifier j.

The compiler will show you in which line it thinks there is a problem. Show us the code near that line.
 
Bob Matthews
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Pawel

I am getting the error on line 1 of my code

Bob M
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what is this line 1? Can you show us?
Line 1 is usually a package statement.
Or an import if you use default package.
Or a class declaration if you use default package and don't use imports.

Do you have a class named j in your project?
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will by now have seen that class names like AAA do not produce simplicity, but confusion.
Have you written
import j ava.util.Something;
by mistake?
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And beside what you have been told already about confusing class name, you should spend more time on choosing all other variable names. Also, follow right Java naming convention. Moreover - format code properly, as line 6 suppose to be shifted by 4 spaces to the right hand side, actually the same as line 2. To conclude this - in your code is more confusion than clarity. Please take seriously what you have been told in posts above, as these bad habbits from the early time leads to a bad practices and error prone code.
 
Bob Matthews
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to everybody for your helpful comments

Bob M
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which method is the code you have posted inside of? I suspect you have placed that code in a location it is not allowed to be.

Post your whole class here (everything in that file).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!