Skip to main content
gamedev.net
🔒 Locked

[java] can interface has data members?

Started by wah_on_2 Apr 1, 2002 at 10:31 PM 29 replies 2.5k views
Original Post
wah_on_2
wah_on_2
can interface has data members? Thanks something like that:
  
interface UI
{
   protected Vector Cntl;   //<- can do this?

   
   public void Draw();
}
  
Fruny
Fruny
RTFM
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
mjacobsca
mjacobsca
An interface cannot have data members, but it can have constant variables. This makes interfaces well suited for enumeration type data (replacing the C++ enumeration).
Neophyte
Neophyte
And when you *do* RTFM, you''ll discover the answer is no.

-Neophyte

- Death awaits you all with nasty, big, pointy teeth. -
wah_on_2
wah_on_2
ic. thank you
Tac-Tics
Tac-Tics
Have you ever notice Java doesn''t really have a manual? It has some very nice but somewhat hard-to-find documentation tho.
Fruny
Fruny
quote:
Original post by Tac-Tics
Have you ever notice Java doesn''t really have a manual? It has some very nice but somewhat hard-to-find documentation tho.


There are plenty of books. Including some by Sun.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
NuffSaid
NuffSaid
You could;ve coded it out and tried it for yourself. That plus checking the manuals would have given you the answer.

Oh and as for downloading the SDK docs, as far as JDK 1.4 is concerned, the docs are on the same download page as the JDK.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Chaoslab
Chaoslab
From what I remember variables are fine in interfaces but have to be public static final.

Real coders never RTFM.

Real coders never have any bugs

Real coders don''t have a life

Real coders never design code

Real coders never comment code

Oops there aren''t any real coders!

:-)

ujhkfkfk
jenova
jenova
quote:
Original post by Chaoslab
From what I remember variables are fine in interfaces but have to be public static final .



already stated here....

quote:
Original post by mjacobsca
An interface cannot have data members, but it can have constant variables. This makes interfaces well suited for enumeration type data (replacing the C++ enumeration).



To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
CaptainJester
CaptainJester
Java has the best set of docs I have ever seen. One is the API docs, which is free. The other is The Java Tutorial, which the online version is free. Both can be found at Sun''s Java website.

---
Make it work.
Make it fast.

"Commmmpuuuuterrrr.." --Scotty Star Trek IV:The Voyage Home
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][
Tac-Tics
Tac-Tics
>> The docs aren''t exactly hard to find:
http://java.sun.com/docs/

Nothing''s hard to find if you have a direct link to it ^_^

>> There are plenty of books. Including some by Sun.

As I said before, nothings hard to find if you have a direct link to it.... it''s a simple question with a simple boolean-format answer. So why not ask on a forum instead of looking up in some stuffy text, right?

NuffSaid
NuffSaid
Because you learn better by experimenting yourself, not by asking ridiculously simple questions (e.g. something that''s in the manual).

Search engines now are very sophisticated and you''ll get to find what you''re after in a jiffy. We''ll need Oluseyi to patrol this board too
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Wrathnut
Wrathnut
Alright guys, lay off of him.

It really pisses me off when someonw says RTFM to just about anything someone asks just because it is easy for the person who already knows the answer(whether it is easy to find or not). If the answer was that goddamn easy then just tell them instead of wasting the space to tell them to read the manual. It seems like a really hostile attitude to take towards someone who is obviously learning. There hasn''t been anything (besides life) that has cut into me learning a language more that one person saying RTFM and then everyone esle piping up and saying the same damn thing. I''m trying to get into a stupid argument here but if you have the time to post a stupid message like that then you have the time to post a stupid answer to a question you already know..

-Just when you think things are starting to look up, life grabs you by the jaws makes you open up wide and sh*ts down your throat.
Enjolras
Enjolras
Quit whining and RTFM

Tac-Tics
Tac-Tics
When someone replies with a RTFM, it implies three things:
1) They understand the topic.
2) They''re easily aggrivated.
3) They are useless.
bloemschneif
bloemschneif
what the hell is RTFM??
unwritten letters
Neophyte
Neophyte
Read The F$#*! Manual.

-Neophyte

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GED d- s:+ a- C++$ UL++ P++ L++ E W+ N+ o K? w !O M--(+) V-- PS+
PE Y+ PGP t-- 5++ X+ R(+) rv+(++) b+++ DI+ D(+) G e+>++ h r--> y+
----- END GEEK CODE BLOCK-----
geekcode.com
NuffSaid
NuffSaid
quote:
Original post by Tac-Tics
When someone replies with a RTFM, it implies three things:
1) They understand the topic.
2) They''re easily aggrivated.
3) They are useless.


I''ve found that you learn a lot better by making an effort to find the answer, before asking people questions.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Arild Fines
Arild Fines
Lets see:

  
public interface MyInterface
{
public int Foo;
}


javac MyInterface.java



Thats exactly 9 typed words. This would have given a definite answer to the question, without having to wait for an answer on these boards. In contrast, the original post had 20 typed words, including a similar example.
What would have been faster, you think?

--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.