This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Switch sends my class object to the trash 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 "Switch sends my class object to the trash" Watch "Switch sends my class object to the trash" New topic
Author

Switch sends my class object to the trash

Bryce Heath
Greenhorn

Joined: Sep 16, 2011
Posts: 19
Hi guys
Heres my new problem for the night, im going to post the driver code so you can see what im trying to do. See first comment for the problem. Thank you.

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Hi
its asking to which account you have to deposit.
First user has to enter his account number or the system has to fetch the account details by name.


Technically,
you have to initalize local valiables.


-Chiru
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

You are not initializing the variable acct1 anywhere in your code, so Java will complain when you try to use the variable (in lines 33 and 34).

You need to initialize it, by creating a new Account object somewhere and assigning it to the variable. For example:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37907
    
  22
As I said yesterday.

Make sure your declarations have the correct scope.
I think at this stage you are getting a method which is much too large. Try this, or something similar:Now you have got your method down to a manageable size, and the action takes place elsewhere.
 
jQuery in Action, 2nd edition
 
subject: Switch sends my class object to the trash
 
Similar Threads
Just Can't figure it out and it's due today
Having troubles with a complex program, need help with an illegal start of type error.
Bank program class or switch problem
Need help with username and password validation
Scanner Strings and Ints dont play nice