I keep finding both on here and Google people having troubles going from long
to int
and not the other way around. Yet I'm sure I'm not the only one that has run into this scenario before going from int
to Long
.
The only other answers I've found were "Just set it as Long in the first place" which really doesn't address the question.
I initially tried casting but I get a "Cannot cast from int to Long
"
for (int i = 0; i < myArrayList.size(); ++i ) {
content = new Content();
content.setDescription(myArrayList.get(i));
content.setSequence((Long) i);
session.save(content);
}
As you can imagine I'm a little perplexed, I'm stuck using int
since some content is coming in as an ArrayList
and the entity for which I'm storing this info requires the sequence number as a Long.
int
tolong
first, then assignlong
toLong
. e.gint x = 2; Long y = (long)x;
– Wafer