• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error: identifier expected Help?  RSS feed

 
Tyler Miller
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I'm trying to complete a homework assignment for my first java class, and it's been a struggle.
The compiler is telling me that my error is "hello.providePrintServices();"






The imported file:




Can anyone offer some help?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

What's wrong: Lines 10 and 11 of your first piece of code are outside a method. You cannot have arbitrary statements outside of a method like that. Those two lines need to be put into a method. For example:

And if you want them to be executed, then you must call that method someMethod() from somewhere.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!