Comparing two objects

Joined
Feb 13, 2009
Messages
1
Reaction score
0
When you create a method that compares two objects and it's arguments are of a type of another class, do you have to do some sort of casting if you get a incompatible type error? Is it even possible to cast a String into a another class or vice versa. Heres the code I have so far

Code:
class Object{

  String Object;


}


Code:
public class Equals  {
	
	    
 public static Object object(Object zero1, Object zero2) {
	
	zero1 = "hello";        
        zero2 = str1;

        System.out.println("Same object? " + (zero1 == zero2));
   
    }
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top