LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-05-2005, 03:42 AM   #1
kpachopoulos
Member
 
Registered: Feb 2004
Location: Athens, Greece
Distribution: Gentoo,FreeBSD, Debian
Posts: 705

Rep: Reputation: 30
java ADT


Hi,
when i create an ADT class in Java, must i declare it "abstract"? I mean are "abstract" classes directly connected to ADTs? I think the concept of ADTs exists in other OO languages and is not specific to Java.
Thanks
 
Old 11-05-2005, 05:33 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I guess by ADT class you mean what is called in java an interface.
 
Old 11-05-2005, 01:53 PM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
You can absolutely have an "abstract data type" in Java without declaring the class "abstract", and/or without creating an interface.

The difference between an "abstract class" and an "interface" in Java is definite - but fairly subtle. The practical bottom line is:

1. For every class, you'll want that class to do one, distinct thing, and do it well.
Every class will always have a definite purpose, and a clear "interface".

2. Your first choice will generally be "inheritance" (e.g. the canonical "class circle extends shape")
Inheritance always expresses an "is-a" relationship (a "circle" unquestionably IS-A "shape")

3. You may declare the top-level ancestor class "abstract", but you usually don't have to.

4. In Java, you'll usually find yourself using "interfaces" when C++ programmers might be looking at "abstract classes" or (ugh!) "multiple inheritance".

If you're curious (and/or if none of stuff I've been babbling makes any sense whatsoever), I'd strongly encourage you to get a copy of Bruce Eckel's (brilliant!):

http://www.bookpool.com/sm/0131002872

Your .. PSM

PS:
You can implement ADT's in any language. OO languages simply offer (much!) better support. But I would argue that the Linux device driver API and the Unix standard I/O libraries both offer excellent examples of ADT's in C.

Here's a worthwhile link on ATD's:

http://en.wikipedia.org/wiki/Abstract_data_type
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java plugin installed correctly for Firefox but not able to view any java applet tvn Linux - Software 10 04-15-2010 02:13 AM
Java Programming: Java Runtime Environment not found when trying to compile murbz Linux - Software 2 03-26-2009 03:04 AM
Problems with Java Web Start (java 1.4.2 - 1.5.0) on Slackware Egy Slackware 11 05-10-2005 06:30 AM
Web start java not working (java works fine) powadha Debian 5 06-05-2004 12:57 PM
2 Questions: java calling system commands? PERL vs Java? randomx Programming 28 11-28-2003 08:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration