write recursive method in java & C#

I want to convert this simple C# code to java :

public int CompareTo(object obj)
return _destIndex.CompareTo(((DiffResultSpan)obj)._destIndex);

and my java code is :

public int compareTo(object obj)
return destIndex.compareTo(((DiffResultSpan)obj).destIndex);

but my code has error : "int can not be dereferenced". I coded it in net-beans. Apparently it's true.but I don't know what should I do ?!!


oh thanks.i found it! int in java is not object.and I should convert it! for example :

new Integer(destIndex).compareTo... 


int in Java is a primitive type, meaning it has no methods or fields. If you want your compare method to compare two objects based on an int, the following should do fine:

return destIndex - ((DiffResultSpan)obj).destIndex;

If destIndex could be negative, there's a chance of integer overflow, so you would have to do:

int otherIndex = ((DiffResultSpan)obj).destIndex;
return destIndex < otherIndex ? -1 : (destIndex > otherIndex ? 1 : 0);

Need Your Help

Error while compiling telerik silverlight project for RadGanttView

visual-studio-2010 silverlight telerik

I recently upgraded to Silverlight 5 and was created silverlight project through

Case sensitivity in SQL Server 2005

sql-server sql-server-2005 case-sensitive

I have a stored procedure in which I declare a variable DECLARE @intCount int and use it throughout the stored procedure as @intcount.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.