errors in java when trying to call objects, setters getters and constructors -


when try call object different class , make setters , getters , make constructors in java eclispe keeps coming errors saying "duplicate local variable myclasstwoobject syntax error, insert "}" complete methodbody

at myclass.main(myclass.java:180)"   enter code h    /*calling object myclasstwo example      *calling object myclasstwo example       */  myclasstwo  myclasstwoobject = **new myclasstwo();** myclasstwoobject.chicken(); system.out.println(); system.out.println();     /*example of return statement     *example of return statement     */  int x =  returnseventyseven();     system.out.print(x); system.out.println();   int result = square(3); system.out.println(); system.out.println(result); system.out.println();    /*getters & setters example     *getters & setters exaple     */  myclasstwo obj1 = **new myclasstwo();**   obj1.setx(25); system.out.print(obj1.getx());    myclasstwo **myclasstwoobject** = new myclasstwo("dog"); myclasstwoobject.neck()**;**ere 

all code has been flagged wrong eclipse in bold

this line here problem:

myclasstwo myclasstwoobject = new myclasstwo("dog");

you creating , assigning second object same name, either need give different name, or if wish change object variable points to, can put:

myclasstwoobject = new myclasstwo("dog");

note convention variables in java use camelcase starting lower case letter.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -