Is it possible to Compare golbalized variables.. ie use them in If/Else Statements??
for example i have globalized some variables using the flowing class
class Global
{
public static
String name1 ;
public static String name2 ;
}
And later on in other classes when i call these local classes
eg. later on i used the folling statements in anther class....
if(Global.name1==Global.name2)
{
System.out.println("same");
}
else
{
System.out.println("diff");
}
Where Global.name1 and Global.name2 were defined in two other totally seperate classes as "
Global.name1 = "hello";
and
Global.name1 = "hello";
note that they are the same strings.. they have the same value
..and when the program loads it prints "diff" becasue of the if and else statements shown before. They never print same..why is this?