PDA

Click to See Complete Forum and Search --> : Can i create a Struct or a type in Java?


nievesj
Dec 6th, 2000, 03:49 PM
Can i create a Struct or a type in Java, like in C/C++
Struct{
... ...
... ...
... ...
};?
or in VB

Type
...
...
...
End type?

I need to do that to put it in a random file.
thanks.

Dec 6th, 2000, 07:19 PM
Objects are an advanced evolution of Struct / Type.

An object is an instance of a class.

Classes are types so to speak. Data Types, but much more. Also they are struct(ures) so to speak.

A class without methods (functions), only attributes (member variables) is what you seek.


class MyClassIsAstructOrAtype{
int a;
String b;
ComplicatedObject c;
}


Java is even fond of saying that everything in Java is a class. So technically, everything in Java is a struct or type.

In short, every Java app or applet is a struct or type or new class. Notice the .class extension.