Click here to Skip to main content
15,891,033 members
Home / Discussions / Java
   

Java

 
GeneralRe: Setting Path Variable Permanently?? Pin
AmbiguousName24-Feb-10 3:31
AmbiguousName24-Feb-10 3:31 
AnswerRe: i want toimplement dfs and bfs code in java by reading data from files Pin
Richard MacCutchan20-Feb-10 4:15
mveRichard MacCutchan20-Feb-10 4:15 
QuestionMultiObject Problem Pin
002comp17-Feb-10 1:52
002comp17-Feb-10 1:52 
AnswerRe: MultiObject Problem Pin
Nagy Vilmos22-Feb-10 21:59
professionalNagy Vilmos22-Feb-10 21:59 
QuestionWhat is this project asking me to do??? Pin
polska0316-Feb-10 10:36
polska0316-Feb-10 10:36 
AnswerRe: What is this project asking me to do??? Pin
Richard MacCutchan16-Feb-10 12:03
mveRichard MacCutchan16-Feb-10 12:03 
QuestionJLayer Pane Pin
Jay-Tech15-Feb-10 17:21
Jay-Tech15-Feb-10 17:21 
Question== String comparison [modified] Pin
AnnnS11-Feb-10 2:28
AnnnS11-Feb-10 2:28 
Hi All,
I have a doubt.
I was just trying out some basic things in Core Java.
Here is the code

public class Test {
public static void main(String args[]) {
String a = "Hai";
String b = "Hai";
if(a == b) {
System.out.println("Equal");
} else {
System.out.println("Not Equal");
}
}
}

I Assumed that the result would be "Not Equal" as == does reference comparison. But I got the answer as "Equal".

Then I tried the second code
public class Test {
public static void main(String args[]) {
String a = "Hai";
a += "";
String b = "Hai";
if(a == b) {
System.out.println("Equal");
} else {
System.out.println("Not Equal");
}
}
}

Now i could get "Not equal". But logically both codes are same.
Why is this so?? Does Java share similar Objects??

Can anyone give an explanation on this??

Thanks,
Annns...Confused | :confused:
modified on Thursday, February 11, 2010 8:38 AM

AnswerRe: == String comparison Pin
Richard MacCutchan11-Feb-10 4:26
mveRichard MacCutchan11-Feb-10 4:26 
GeneralRe: == String comparison Pin
AnnnS11-Feb-10 4:31
AnnnS11-Feb-10 4:31 
AnswerRe: == String comparison Pin
Nagy Vilmos22-Feb-10 22:32
professionalNagy Vilmos22-Feb-10 22:32 
GeneralRe: == String comparison Pin
AmbiguousName7-Mar-10 20:41
AmbiguousName7-Mar-10 20:41 
GeneralRe: == String comparison Pin
Nagy Vilmos7-Mar-10 22:22
professionalNagy Vilmos7-Mar-10 22:22 
QuestionJavascript File upload Pin
Kushi Bobby7-Feb-10 17:18
Kushi Bobby7-Feb-10 17:18 
AnswerRe: Javascript File upload Pin
42774807-Feb-10 18:06
42774807-Feb-10 18:06 
AnswerRe: Javascript File upload Pin
Richard MacCutchan7-Feb-10 22:31
mveRichard MacCutchan7-Feb-10 22:31 
JokeRe: Javascript File upload Pin
42774808-Feb-10 0:21
42774808-Feb-10 0:21 
GeneralRe: Javascript File upload Pin
Richard MacCutchan8-Feb-10 0:35
mveRichard MacCutchan8-Feb-10 0:35 
GeneralRe: Javascript File upload Pin
42774808-Feb-10 0:38
42774808-Feb-10 0:38 
QuestionPhyton to Java Pin
BombayGuy5-Feb-10 12:32
BombayGuy5-Feb-10 12:32 
AnswerRe: Phyton to Java Pin
42774805-Feb-10 20:32
42774805-Feb-10 20:32 
QuestionSlot Machine Java Help [modified] Pin
bmnot4-Feb-10 23:48
bmnot4-Feb-10 23:48 
AnswerRe: Slot Machine Java Help Pin
Richard MacCutchan5-Feb-10 1:00
mveRichard MacCutchan5-Feb-10 1:00 
GeneralRe: Slot Machine Java Help Pin
bmnot8-Feb-10 11:21
bmnot8-Feb-10 11:21 
GeneralRe: Slot Machine Java Help Pin
Richard MacCutchan8-Feb-10 11:36
mveRichard MacCutchan8-Feb-10 11:36 

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.