
-----------------------------------
Martin
Tue Oct 04, 2005 4:01 am

typedef in Java?
-----------------------------------
Is there anything equivalent to typedef in Java?

-----------------------------------
rizzix
Tue Oct 04, 2005 9:43 am


-----------------------------------
No.

-----------------------------------
wtd
Tue Oct 04, 2005 12:03 pm


-----------------------------------
What are you trying to accomplish?  Perhaps we can help you find something that's functionally equivalent.

-----------------------------------
Martin
Tue Oct 04, 2005 9:10 pm


-----------------------------------
Just trying to shorten some variable declarations is all.

Actually, I was trying to figure out if there was something similar to #define (so I could define a for-each loop in java 1.4.2) and then I realized that I couldn't use typedef either.

-----------------------------------
wtd
Tue Oct 04, 2005 9:16 pm


-----------------------------------
The lack of text-substitution macros is a good thing.

The lack of macros is not so good.

-----------------------------------
[Gandalf]
Tue Oct 04, 2005 10:18 pm


-----------------------------------
I was going to ask something similar, so there are no structs, or anything like that in Java?  I was trying to think of ways other than classes, and read some in my C book...

-----------------------------------
wtd
Tue Oct 04, 2005 10:41 pm


-----------------------------------
No, there are not structs in Java.  But then, structs in C++ are not really structs either.  :)

-----------------------------------
[Gandalf]
Tue Oct 04, 2005 10:44 pm


-----------------------------------
So most (all) organization is done with classes?
Indeed...  Just for the record, I was not neglecting to put the ++, it was a C book that I was reading :).

-----------------------------------
wtd
Tue Oct 04, 2005 10:49 pm


-----------------------------------
"]So most (all) organization is done with classes?

Yes, all organization is done within the context of a class.

-----------------------------------
Martin
Tue Oct 04, 2005 10:56 pm


-----------------------------------
Just make a class and make all of the member variables public. There, you have a C++ struct.

-----------------------------------
[Gandalf]
Tue Oct 04, 2005 11:18 pm


-----------------------------------
Sure, but then that would be an improper class, right? :)

-----------------------------------
wtd
Tue Oct 04, 2005 11:33 pm


-----------------------------------
From an OOP standpoint, yes.  Very much so.

-----------------------------------
Martin
Wed Oct 05, 2005 12:22 am


-----------------------------------
But really, that's all that C++ structs are - classes with member variables public by default.

-----------------------------------
wtd
Wed Oct 05, 2005 1:38 am


-----------------------------------
Member variables and member functions public by default.
