Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

abstract variable  RSS feed

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to All,

Can you please tell me what is the meaning of abstract variable. where is the use and benefit of making a variable abstract??
 
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here follow 2 meanings of word abstract:
A concept or idea not associated with any specific instance.
A sketchy summary of the main points of an argument or theory.

There is nothing like 'abstract variable' in Java. We have 'abstract classes' and 'abstract methods'. Try to relate the meaning of word 'abstract' with 'abstract classes' and 'abstract methods'.

Hope that helps,
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot have a variable declared as abstract in java. What is your requirement? Why do you need abstract variable? Can you provide more details?
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Krithika Srinath:
You cannot have a variable declared as abstract in java. What is your requirement? Why do you need abstract variable? Can you provide more details?



Aloha Krithika,

Think of it this way. Java defines only abstract classes and methods (as far as I've read so far). Abstract implies that the abstract methods within abstract classes must be coded. A variable cannot be coded because it is a primitive or reference that can only be assigned a value.

You cannot do something like this:


It is like trying to fit a square peg in a round hole, or using kitchen utinsels for farming .

Hope this example helps...
Aloha,
Doug
 
Krishna Acharya
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Krithika!
I have read about abstract variable somewhere in Kathy-Book. I was just wondering about this. Now, there is no confusion. You are right.
Thanks.
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!