aspose file tools*
The moose likes Beginning Java and the fly likes inner class problem:  cannot assign twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inner class problem:  cannot assign twice" Watch "inner class problem:  cannot assign twice" New topic
Author

inner class problem: cannot assign twice

Steve Bret
Greenhorn

Joined: May 03, 2006
Posts: 6
Why can't I say :
zz2 = z;
after the line
double zz2 = z;
??

thanks

Below the code.
Steve Bret
Greenhorn

Joined: May 03, 2006
Posts: 6
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

Joined: Feb 07, 2005
Posts: 2367
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

Joined: Aug 03, 2002
Posts: 7729
You are putting an assignment statement where only definitions are allowed.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inner class problem: cannot assign twice