wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Error displayed at println statement. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error displayed at println statement." Watch "Error displayed at println statement." New topic

Error displayed at println statement.

Joy Vergis
Ranch Hand

Joined: Sep 14, 2009
Posts: 45

i am new to java. I writing a program in eclipse. I get error at the println statement.


package package1;

public class ClassA {
String str1="a-b";

int a= str1.length(); //error at this line.


Error displayed in eclipse:
Syntax error on token "println", Identifier expected after this token.

Please help
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11161

you can't have code outside a method. you can declare variables, but you can't call methods or really 'do' stuff.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Pankaj Rathod

Joined: Feb 02, 2009
Posts: 7
Also you are calling System.out.println() without any argument.
Greg Brannon

Joined: Oct 24, 2010
Posts: 557
You could start with the almost-obligatory "HelloWorld.java" program that teaches basic program structure and the elements required. You can find a tutorial using an appropriate Google search that either shows how to create and run the program using a basic text editor at the command line (recommended) or using Eclipse. If you've decided on Eclipse as your IDE, construct and run the HelloWorld program using both the command line and IDE approaches so that you see what Eclipse does for you and have an idea what you'll have to do without Eclipse.

Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38025
Pankaj Rathod wrote:Also you are calling System.out.println() without any argument.
What's wrong with that? Look in the documentation and see whether it is permissible.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38025
Don't use Eclipse or other IDEs at this stage.
subject: Error displayed at println statement.
Similar Threads
Getting exception with buffered loop...
problem in System.out.println
No suitable driver problem
When to use keyword "const"? Just a reserved word.
Boxing/Unboxing and equality