Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to achieve abstraction in java

 
Praveen palukuri
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank u
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inheritence. Use abstract classes and interfaces.

My pleasure..

/Svend Rost
 
Marilyn de Queiroz
Sheriff
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a method. That method will do something. When calling the method, you are not concerned about how the method does what it does. That's abstraction.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many definitions of abstraction, but it's about ignoring certain details so you can focus on larger issues. One definition says it's not about being imprecise but finding a new language about the problem so you can be more precise.

In Java abstraction is often about referring to an abstract type - a superclass or interface - rather than a concrete type. I might make a method that refers to List:

You might call my method with an ArrayList or a LinkedList. By ignoring the detail of the exact type I can focus on the big picture of what I want to do with the list.

Does that help?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic