Java uses interface where C++ would use typedef. The difference is that an interface can be the alias for any one of a set of otherwise unrelated classes that share some defined state and behavior, while a typedef represents a single entity.
SCJP 1.4, SCWCD in process
anil kumar bolisetti
Joined: Jan 05, 2005
Thank you Mike for your reply. But my question has been answered yet. consider a C program as: typedef float myfloat; so we can declare a float variable as: myfloat a;
My question is: Is there any provision to give alias name like this in java.
Joined: Mar 13, 2004
What exactly are you trying to do?
I used typedef in C programs to make a struct act like a C++ class.
There are some new capabilitis in Java 5, like autoboxing and generics, that may meet your needs.
The answer is no. A common use for typedef is to, let's say, defer choosing between float and double, and allow you to easily change code that uses one to use the other. Java doesn't have any such feature.
Although this is inconvenient sometimes, the convenience in C/C++ comes at a price: if you look at a C/C++ program, you don't necessarily know what you're dealing with unless you look at all the header files included by the file you're looking at. In Java, what you see is what you get -- Java code isn't as "tricky" and is thus easier to understand.