Int cannot be dereferenced

hiya my code is below:

public void sortByTimeByHour()
	{
		Collections.sort(messageList, new Comparator()
		{
			public int compare(Object o1, Object o2)
			{
				int t1 = ((Message) o1).getHour();
				int t2 = ((Message) o2).getHour();
				
				return t1.compareTo(t2);
			}
		});
	
	}

but i get the error message “int cannot be dereferenced” why? and how can I solve this?

btw getHour() returns an int

Thanx

an int is a primitive, not an Object. As such, it doesn’t have any ‘sub’ parts to reference.

You could do something like:

return new Integer( t1 ).compareTo( new Integer( t2 ) );

but why?

return t1 - t2;

will return the same result.

Thanx alot that compiles now