Results 1 to 3 of 3
Thread: Trying to initialize variables
- 10-14-2009, 10:12 PM #1
Member
- Join Date
- Oct 2008
- Location
- Washington, US
- Posts
- 28
- Rep Power
- 0
Trying to initialize variables
Hi, I'm having a little trouble with the introduction of the final modifier. I'm doing a bankAccount homework assignment, however I ran into my first problem.
Java Code:public class BankAccount implements NamedAccount { private String name ; private double iRate ; private double balance ; public BankAccount(final String nameOfOwner, final double interestRate) { }
Except there's the final modifier in front of nameOfOwner and interestRate. Also I cannot change the method signature in anyway either.
So my question is, how do i do such a task =/ Thanks
- 10-14-2009, 10:21 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 14
You can't change the values of final variables once they are assigned. That is where they get get their name (final) from. You probably don't want to do nameOfOwner = name but name = nameOfOwner instead. The two are different.
Last edited by r035198x; 10-14-2009 at 10:31 PM.
- 10-14-2009, 10:30 PM #3
Member
- Join Date
- Oct 2008
- Location
- Washington, US
- Posts
- 28
- Rep Power
- 0
Similar Threads
-
What are Instance variables and static variables?
By sandeshforu in forum New To JavaReplies: 3Last Post: 09-09-2009, 05:48 PM -
ObjectInputStream does not initialize
By Singing Boyo in forum New To JavaReplies: 1Last Post: 06-03-2009, 08:11 AM -
How to initialize an Array
By Java Tip in forum java.langReplies: 0Last Post: 04-14-2008, 08:47 PM -
Initialize variables before use
By Java Tip in forum Java TipReplies: 0Last Post: 12-22-2007, 11:22 AM -
I do not know how to initialize the two variables
By Daniel in forum Advanced JavaReplies: 2Last Post: 07-01-2007, 04:42 AM
Bookmarks