Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Java doesn't support structures ? (Just out of curiosity)

Tags:

java

struct

I know you can use public fields, or some other workarounds. Or maybe you don't need them at all. But just out of curiosity why Sun leave structures out.

like image 213
1392023093user Avatar asked Nov 24 '14 16:11

1392023093user


1 Answers

Here's a link that explains Sun's decision:

2.2.2 No More Structures or Unions

Java has no structures or unions as complex data types. You don't need structures and unions when you have classes; you can achieve the same effect simply by declaring a class with the appropriate instance variables.

like image 101
M A Avatar answered Sep 22 '22 13:09

M A