aspose file tools*
The moose likes Beginning Java and the fly likes array of Structures in java ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "array of Structures in java ?" Watch "array of Structures in java ?" New topic
Author

array of Structures in java ?

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1378
How to create array of Structures in java ?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

kri shan wrote:How to create array of Structures in java ?

Are you sure, there is "Structure" in Java?

Or you can define a class, with the attribute you want store in "Structure", something like

and can define array,



and this How "Structure" in C are incorporated into "Classes" in C++
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39425
    
  28
Beware of drawing analogies from C and C++; lots of people get confused when they go from C/C++ to Java because they think the three languages are the same . . . and they aren't

Yes, as you have already been told, you can have Structure[] arrays, but you cannot have Structure<E>[] arrays, ie arrays of classes with a formal generic type parameter.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Well, you can declare it that way, you just can't create it like that. But with a bit of casting and ignoring / suppressing a warning it is possible to create such an array:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: array of Structures in java ?