Click here to Skip to main content
16,012,223 members
Home / Discussions / Java
   

Java

 
AnswerRe: converter video Pin
Marco Bertschi19-Nov-13 20:18
protectorMarco Bertschi19-Nov-13 20:18 
AnswerRe: converter video Pin
Bernhard Hiller19-Nov-13 22:06
Bernhard Hiller19-Nov-13 22:06 
QuestionWeb WCF Pin
SheraX19-Nov-13 5:11
SheraX19-Nov-13 5:11 
QuestionUnderstanding Java Integer Pin
Raptor8118-Nov-13 10:05
Raptor8118-Nov-13 10:05 
AnswerRe: Understanding Java Integer Pin
Richard MacCutchan18-Nov-13 22:28
mveRichard MacCutchan18-Nov-13 22:28 
GeneralRe: Understanding Java Integer Pin
jschell19-Nov-13 10:49
jschell19-Nov-13 10:49 
GeneralRe: Understanding Java Integer Pin
Richard MacCutchan19-Nov-13 21:41
mveRichard MacCutchan19-Nov-13 21:41 
AnswerRe: Understanding Java Integer Pin
jschell19-Nov-13 10:58
jschell19-Nov-13 10:58 
Raptor81 wrote:
In my experience, seems that Java does reference comparison with two Integers


Does exactly that for equality and inequality. If it didn't it wouldn't be backwards compatible.

Raptor81 wrote:
and seems that it does value comparison with one Integer and one constant.


Yes however the problem with doing that is that one can then forget about equality and inequality. And that becomes even more of a problem because java caches integers in the 0 to 128 range. So simple tests can succeed and then fail in production when bigger values are used. (Keep in mind that the range of integers that are cached is not part of the specification so it can change.)

So the best idea is to never rely on the operators in the first place.


This is demonstrated with the following.

Integer a1 = 1000;
Integer a2 = 1000;
Integer a3 = a1;
Integer b1 = 10;  // Less than 128 so Integer is cached.
Integer b2 = 10;

System.out.println("1000 is " + (a1 == a2));
System.out.println("10 is " + (b1 == b2));

System.out.println("1000 != is " + (a1 != a3));

AnswerRe: Understanding Java Integer Pin
Oscar020-Nov-13 6:35
Oscar020-Nov-13 6:35 
Questiontrying to find the real import files Pin
tiwal17-Nov-13 21:10
tiwal17-Nov-13 21:10 
AnswerRe: trying to find the real import files Pin
Richard MacCutchan17-Nov-13 22:32
mveRichard MacCutchan17-Nov-13 22:32 
GeneralRe: trying to find the real import files Pin
tiwal17-Nov-13 23:35
tiwal17-Nov-13 23:35 
GeneralRe: trying to find the real import files Pin
Richard MacCutchan18-Nov-13 0:43
mveRichard MacCutchan18-Nov-13 0:43 
GeneralRe: trying to find the real import files Pin
tiwal18-Nov-13 1:18
tiwal18-Nov-13 1:18 
AnswerRe: trying to find the real import files Pin
Oscar020-Nov-13 6:54
Oscar020-Nov-13 6:54 
QuestionOpenGTS with eclipse Pin
Member 1026351915-Nov-13 23:54
Member 1026351915-Nov-13 23:54 
AnswerRe: OpenGTS with eclipse Pin
Richard MacCutchan16-Nov-13 0:17
mveRichard MacCutchan16-Nov-13 0:17 
GeneralRe: OpenGTS with eclipse Pin
Member 1026351916-Nov-13 0:43
Member 1026351916-Nov-13 0:43 
Questionhelp!!! seasar framework ... Pin
thetime110214-Nov-13 17:47
thetime110214-Nov-13 17:47 
AnswerRe: help!!! seasar framework ... Pin
Richard MacCutchan14-Nov-13 21:40
mveRichard MacCutchan14-Nov-13 21:40 
GeneralRe: help!!! seasar framework ... Pin
thetime110214-Nov-13 22:12
thetime110214-Nov-13 22:12 
AnswerRe: help!!! seasar framework ... Pin
Marco Bertschi14-Nov-13 21:56
protectorMarco Bertschi14-Nov-13 21:56 
GeneralRe: help!!! seasar framework ... Pin
thetime110214-Nov-13 22:18
thetime110214-Nov-13 22:18 
GeneralRe: help!!! seasar framework ... Pin
Marco Bertschi14-Nov-13 22:23
protectorMarco Bertschi14-Nov-13 22:23 
QuestionSearch data in Java RMI Pin
Cyber1213-Nov-13 21:26
Cyber1213-Nov-13 21:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.