File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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.
 
Don't get me started about those stupid light bulbs.
 
subject: inner class problem: cannot assign twice
 
Similar Threads
Local Class in a Static Method
inner class instantiation
0.1 + 0.2 is not equal 0.3
need help again
Default values for static variables