Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will structs and value types (like C#'s) be included in Java 7?

Will structs and value types (like C#'s) be included in Java 7?

like image 477
Mr. Red Avatar asked Jul 30 '10 14:07

Mr. Red


People also ask

Are structs value types in C?

So, each struct contains only values for value types, and/or references to reference types, which are of a known size. And as a result, the struct is a value type that stores its contents in memory allocated on the stack.

Is struct reference type or value type?

Structs are value types, while classes are reference types, and the runtime deals with the two in different ways. When a value-type instance is created, a single space in memory is allocated to store the value. Primitive types such as int, float, bool and char are also value types, and work in the same way.

Are structs in C like classes?

In C++, structs and classes are pretty much the same; the only difference is that where access modifiers (for member variables, methods, and base classes) in classes default to private, access modifiers in structs default to public.

Are structs passed by value in C?

A struct can be either passed/returned by value or passed/returned by reference (via a pointer) in C. The general consensus seems to be that the former can be applied to small structs without penalty in most cases.


1 Answers

Here is John Rose's (an Oracle JVM developer) blog post about this proposal. It has been around for a while, but not as an official JSR. It seems unlikely to happen even in java 9.

http://blogs.oracle.com/jrose/entry/tuples_in_the_vm

like image 111
kristianp Avatar answered Oct 14 '22 09:10

kristianp