File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes what might be the error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what might be the error" Watch "what might be the error" New topic

what might be the error

thirumala raju

Joined: Jan 03, 2008
Posts: 9
hi folks,

package pack1;

class clas2{
String s1;
String s2;
void met(String d1, String d2)

public class rajaone
public static void main(String[] args)
//String s1,s2;
clas2 ref1 = new clas2();
ref1.s2; //error showing here

i am getting this error for the above code the error is :
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error, insert "AssignmentOperator ArrayInitializer" to complete Expression

at pack1.rajaone.main(
Nicolas Stern
Ranch Hand

Joined: Apr 26, 2002
Posts: 57

the line

references the member variable s2 of your instance ref1. Expected is a valid expression or a statement (e.g. an assignment, a method invokation)


hth - cheers
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3381

Hi Thirumala Raju,

please try to make use of CodeTags so that the java code will look nicely.

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3381

Originally posted by thirumala raju:
...hi folks,

What are you trying to achieve in the line in bold? You just used a variable using its reference. But it should be involved in an operation which may be of an assignment, arithmetic etc., The example shown by Nicolas is one kind.

You can call a method like this and leave its return type unassigned to any variable. But it is NOT the case with variables.
I agree. Here's the link:
subject: what might be the error
It's not a secret anymore!