All Questions
Tagged with value-type java
23
questions
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 ...
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
...
-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, ...).
...
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
...
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 ...
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 ...
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 ...
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 ...
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 ...
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);
...
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, ...
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&...
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?...
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 ...
-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 ...