Meaningless Drivel is fun!
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
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

Switch sends my class object to the trash

Bryce Heath

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: 290

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.

you have to initalize local valiables.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

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 8 API documentation
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46397
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.
I agree. Here's the link:
subject: Switch sends my class object to the trash
It's not a secret anymore!