This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes The == operator Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "The == operator" Watch "The == operator" New topic
Author

The == operator

Per Radfe
Greenhorn

Joined: Jul 05, 2007
Posts: 14
import java.util.ArrayList;
import java.util.Vector;
class Main extends Thread{
public static void main(String[] args) {

Vector<Integer> x = new Vector<Integer>();
ArrayList<Double> y = new ArrayList<Double>();

if ( x == y){
System.out.println("test");
}
}
}

This code dose�nt compile. I thought that you could compare any reference variable but obviously not? Is the == operator working like instanceof wich only can compare instances of the same class hierarchy?
Nousheed Mohammed
Greenhorn

Joined: Mar 30, 2007
Posts: 6
Yes, Using == operator we can compare instances of the same class.
Per Radfe
Greenhorn

Joined: Jul 05, 2007
Posts: 14
Ok, thanks.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: The == operator
 
Similar Threads
whizlab question for SCJP1.5
SCJP 5: Mock questions
Generics Question: Why Won't This Code Compile?
Help needed with the Code
Question about Random Number Generation...