3 Replies - 449 Views - Last Post: 10 March 2010 - 05:19 PM Rate Topic: -----

#1 bailey23  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-March 10

static class members

Posted 10 March 2010 - 02:17 PM

I am learning about static class members. I am trying to create a bankaccount that does deposits, withdraws, etc. My code will not compile. It says that inner classes cannot have static declarations static double interestRate. I'm just a little confused. Does anyone havae any ideas for me? Thanks:)

public class account
{
	public class CheckingAccount
	{
		static double interestRate;
		private double balance;
		private int accountNumber;
		private String name;

		//Initalizes the object
		public CheckingAccount ()
		{
			balance = 0;
			accountNumber = 0;
			name = " ";
		}



Edited by Dogstopper: I fixed your code tags. In the future, please do this by yourself, as I don't have the time to fix it every time and placing code in the tags makes it much easier for us DICs to help.

Thanks
~Dogstopper.

This post has been edited by Dogstopper: 10 March 2010 - 05:25 PM


Is This A Good Question/Topic? 0
  • +

Replies To: static class members

#2 NeoTifa  Icon User is online

  • Whorediot
  • member icon





Reputation: 2681
  • View blog
  • Posts: 15,722
  • Joined: 24-September 08

Re: static class members

Posted 10 March 2010 - 03:12 PM

Take the static word out. Also, :code:. Is there a particular reason you have that static there?
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: static class members

Posted 10 March 2010 - 05:16 PM

Inner classes cannot have static variables
However the master class can so you can do somthing like that

public class account
{
     static double checkingInterestRate;

     public class CheckingAccount
     {
        private double balance;
        private int accountNumber;
        private String name;


Was This Post Helpful? 1
  • +
  • -

#4 C++ Programmer  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 20
  • View blog
  • Posts: 548
  • Joined: 12-June 08

Re: static class members

Posted 10 March 2010 - 05:19 PM

Please surround your code in the Code tags please.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1