Structs in Java - URGENT!!!!!

ok guys, I have exhausted all my sources. I need to know how to contrstuct a basic struct in Java with 3 different variables.

I need 2 strings, 4 ints and 1 float.

Can somebody PLEASE help me as this is pretty urgent!

Thanks for any help!
-GhostVR4
 
There is no such thing as a struct in java. But you can do it in a class:
Code:
public class MyStruct {
public String s1, s2;
public int i1, i2, i3, i4;
public float f1;
public MyStruct() {
}
}

Just access than using this code:

MyStruct s = new MyStruct();
s.i1 = 5;

Like that.
 
Originally posted by skip0110
There is no such thing as a struct in java. But you can do it in a class:
Code:
public class MyStruct {
public String s1, s2;
public int i1, i2, i3, i4;
public float f1;
public MyStruct() {
}
}

Just access than using this code:

MyStruct s = new MyStruct();
s.i1 = 5;

Like that.

THANK YOU!

I was wondering why I couldn't find anything on structs.

Again, Thanks a lot!
-GhostVR4
 
hey, no problem! and if any mods are reading this, how about changing the relativly dead "perl" forum to a C/C++/Java forum, since these languages are probably more commonly used by the memebers of this forum.
 
Originally posted by skip0110
hey, no problem! and if any mods are reading this, how about changing the relativly dead "perl" forum to a C/C++/Java forum, since these languages are probably more commonly used by the memebers of this forum.

haha, so true!

also maybe include C# in it...

-GhostVR4
 
Originally posted by skip0110
hey, no problem! and if any mods are reading this, how about changing the relativly dead "perl" forum to a C/C++/Java forum, since these languages are probably more commonly used by the memebers of this forum.

cheeky....

perl is more commonly used that C/C++ in web appilcations..


but yea, a Java forum would be cool.
 

Latest Posts

Back