• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner class problem: cannot assign twice

 
Steve Bret
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why can't I say :
zz2 = z;
after the line
double zz2 = z;
??

thanks

Below the code.
 
Steve Bret
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For info I get this error message:
C:\Java\test>javac -classpath C:\jdk1.5\bin TopLevelA.java
TopLevelA.java:14: <identifier> expected
zz2 = z;
^
1 error
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice that where you have the statement zz2=z, you are in the inner class. You can't simply make an assignment statement where you declare variables. You need to put it in a block.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are putting an assignment statement where only definitions are allowed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic