Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

what might be the error

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Thirumala Raju,

please try to make use of CodeTags so that the java code will look nicely.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Bring out your dead! Or a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic