• Post Reply Bookmark Topic Watch Topic
  • New Topic

error <identifier> expected  RSS feed

 
Vikram Bhati
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys,
I'm new here.

please have a look on this program :


I'm not able to understand 7th line. What is that error?
Please help & Thanks in advance .
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have changed the red writing (difficult to read) to code tags: always use them because (as you see ) they make the code look a lot better. No lines numbers: the code tags add them automatically.
I presume you have worked out that x is only in scope in the fun method, so it is not accessible in the other method. A parameter is in scope for the method it belongs to.
What you have missed is that statements are not allowed outside methods (or constructors or initialisers) so you cannot write System.out.print… outside a method. That is what caused the other error.
 
Vikram Bhati
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


thank you buddy
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome

No need to quote the whole previous post. That simply makes the threads longer and longer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!