Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
0 answers
102 views

Are Value Classes allowed to exhibit change? [closed]

The doc for Value Based Classes specify: Instances of a value-based class: are final and immutable (though may contain references to mutable objects); If I defined a value class Foo, which had a ...
Vince's user avatar
  • 15k
2 votes
0 answers
298 views

Why doesn't Project Valhalla introduce mutable structs?

Looks to me like primitive classes could behave more efficiently (at reasonable sizes) if they weren't immutable as currently proposed, but worked more like C structs. Given this primitive class ...
Julian Durchholz's user avatar
-1 votes
1 answer
681 views

Why "int" is not a class like "String"?

I know this is a weird question and maybe a little vague. Because I myself isn't sure about what I'm really missing. But please hear me out. In java, there are : value types (like int, char, ...). ...
Roo Tenshi's user avatar
0 votes
2 answers
110 views

How to justify Strings in java as reference type? check out the following cases

Case 1: String s1 = "Hello"; String s2 = s1; //now has the same reference as s1 right? System.out.println(s1); //prints Hello System.out.println(s2); //prints Hello ...
Tarun Dadlani's user avatar
3 votes
4 answers
4k views

Converting a Map<String, String> to a Value type with Jedis

So, I have a value type : class Session { long createdAt; List<String> postIds; } Using the jedis client(3.0.0-m1 is that matters), I am currently performing an hset to create the ...
Naman's user avatar
  • 30.6k
0 votes
0 answers
189 views

Are L-world value types (from project valhalla) useless in practice?

I wrote two versions of a program to test the performance impact of object allocations in a java program. One uses simple java objects: class Point { public final double x; public final ...
saga's user avatar
  • 2,073
4 votes
1 answer
261 views

How to generically initialize a value type with its default value?

In the context of Java's Project Valhalla, how can I generically initialize a value type with its default value? Initially, I thought that assigning null to any value type would perform this ...
fps's user avatar
  • 34.2k
4 votes
2 answers
305 views

Can null be assigned to or be compared to a value type variable?

In Java, there have always existed primitive types and references, but not value types. One of the goals of Project Valhalla is to explore and incubate feature candidates such as value types. I ...
fps's user avatar
  • 34.2k
2 votes
1 answer
144 views

Value type confusion

My first question on StackOverflow :) I started to learn Swift in XCode a few days ago and I'm having some trouble understanding the value type in Swift. Since I'm quite familiar with Java, I'm just ...
Clovaf's user avatar
  • 23
0 votes
1 answer
384 views

Java: Does Chronicle Map support different value classes?

I usually create a new Chronicle Map using a ChronicleMapBuilder like so: ChronicleMapBuilder<SomeKey, MyImplClass> builder = ChronicleMapBuilder.of(SomeKey.class, MyImplClass.class); ...
Martin Andersson's user avatar
2 votes
1 answer
68 views

How to put stuff in a hash map and use new instances with the same value of fields to get the corresponding value

I am developing an android app to help little kids learn maths. It will display some questions and the user can answer them. At the start page there would be some options to choose from. For example, ...
Sweeper's user avatar
  • 249k
5 votes
2 answers
2k views

Why java.util.Map value can be primitive array but not single primitive

Here are two examples Map value as Single value private Map<Short, Boolean> _Booleans = new HashMap<Short, Boolean>(); //works private Map<Short, boolean> _Booleans = new HashMap&...
Scavs's user avatar
  • 693
35 votes
4 answers
7k views

What are Value Types from Project Valhalla?

I've started reading about Project Valhalla and there is something I really don't understand and it's the Value Types. This is what I understand: 1) Are objects that can't be compare it as reference?...
chiperortiz's user avatar
  • 4,881
20 votes
3 answers
9k views

Creating Objects on the stack memory in java ?

This is just a simple theoretical question out of curiosity. I have always been like a java fan boy. But one thing makes me wonder why java does not provide mechanism for creating objects on the stack ...
adn.911's user avatar
  • 1,294
-1 votes
4 answers
150 views

Java String type

I have this Java code: String x = "abcgrfdhdrhfhtjfhtgdrfdjrtkkytjgykjgrthfd"; String y = "abcgrfdhdrhfhtjfhtgdrfdjrtkkytjgykjgrthfd"; System.out.println(x == y); It prints out: true How is this ...
Roxana's user avatar
  • 87

15 30 50 per page