Computer Science Canada typedef in Java? |
Author: | Martin [ Tue Oct 04, 2005 4:01 am ] |
Post subject: | typedef in Java? |
Is there anything equivalent to typedef in Java? |
Author: | rizzix [ Tue Oct 04, 2005 9:43 am ] |
Post subject: | |
No. |
Author: | wtd [ Tue Oct 04, 2005 12:03 pm ] |
Post subject: | |
What are you trying to accomplish? Perhaps we can help you find something that's functionally equivalent. |
Author: | Martin [ Tue Oct 04, 2005 9:10 pm ] |
Post subject: | |
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. |
Author: | wtd [ Tue Oct 04, 2005 9:16 pm ] |
Post subject: | |
The lack of text-substitution macros is a good thing. The lack of macros is not so good. |
Author: | [Gandalf] [ Tue Oct 04, 2005 10:18 pm ] |
Post subject: | |
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... |
Author: | wtd [ Tue Oct 04, 2005 10:41 pm ] |
Post subject: | |
No, there are not structs in Java. But then, structs in C++ are not really structs either. |
Author: | [Gandalf] [ Tue Oct 04, 2005 10:44 pm ] |
Post subject: | |
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 . |
Author: | wtd [ Tue Oct 04, 2005 10:49 pm ] |
Post subject: | |
[Gandalf] wrote: So most (all) organization is done with classes?
Yes, all organization is done within the context of a class. |
Author: | Martin [ Tue Oct 04, 2005 10:56 pm ] |
Post subject: | |
Just make a class and make all of the member variables public. There, you have a C++ struct. |
Author: | [Gandalf] [ Tue Oct 04, 2005 11:18 pm ] |
Post subject: | |
Sure, but then that would be an improper class, right? |
Author: | wtd [ Tue Oct 04, 2005 11:33 pm ] |
Post subject: | |
From an OOP standpoint, yes. Very much so. |
Author: | Martin [ Wed Oct 05, 2005 12:22 am ] |
Post subject: | |
But really, that's all that C++ structs are - classes with member variables public by default. |
Author: | wtd [ Wed Oct 05, 2005 1:38 am ] |
Post subject: | |
Member variables and member functions public by default. |