aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what might be the error" Watch "what might be the error" New topic
Author

what might be the error

thirumala raju
Greenhorn

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

package pack1;

class clas2{
String s1;
String s2;
void met(String d1, String d2)
{
System.out.println("ADASD");

}
}
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(rajaone.java:18)
thanks
raja
Nicolas Stern
Ranch Hand

Joined: Apr 26, 2002
Posts: 57
Hi,

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)

examples:


hth - cheers
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

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: 3344

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: what might be the error