Hi,
I am trying to compile a code( which was written and compiled in 1.4) in 1.6.

It gives few errors, when i compile in 1.6
for eg:

compareTo(java.lang.String) in java.lang.String cannot be applied to (java.lang.Object)
if (NatureOfAddress_SidNumber_str.compareTo(vTemp2.elementAt(iLoop)) < 0)

Is there anyway i can suppress the warnings so that it gets compiled in 1.6?

Thanking you,
Shilpa

No, it's not a warning - it's an error. Apparently they removed the compareTo(Object) signature from the String API.

You could either cast the elementAt() to String or explicitly call toString() on it.

If you get 'warnings' about deprecated methods you can turn them off by not passing the -deprecation to the javac command.

If it concerns real 'compiler errors' you will have no other option then to change the code... -i think-

No, it's not a warning - it's an error. Apparently they removed the compareTo(Object) signature from the String API.

You could either cast the elementAt() to String or explicitly call toString() on it.

With the introduction of generics in 1.5 the Comparable interface became Comparable<E> which far better documents it intention.
As a result any class implementing Comparable since 1.5 no longer has a method compareTo(Object o) but a method compareTo() taking a parameter of its own type.
In reality compareTo was always intended to only accept parameters of the type being compared to (or subclasses of it) but the semantics of the language prevented this being enforced at the API level (instead it was intended for enforcement at implementation level).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.