Question about "java.lang.Object.equals()".

public class TestEquals {
  private int a;
  private int b;
  public TestEquals(int a,int b) {
    setA(a);
    setB(b);
  public int getA() {
    return a;
  public void setA(int a) {
    this.a = a;
  public int getB() {
    return b;
  public void setB(int b) {
    this.b = b;
  public static void main(String[] args) {
    TestEquals te01 = new TestEquals(1,2);
    TestEquals te02 = new TestEquals(1,2);
    System.out.println("te01 equals to te02: " + te01.equals(te02));
    te01.setA(2);
    System.out.println("te01 equals to te02: " + te01.equals(te02));
}The result is:
te01 equals to te02: false
te01 equals to te02: false
Why the first case is false?

You didn't override Object.equals() in your TestEquals class. So, you are calling Object.equals(), which just compares reference values. You need to write your own equals() method (presumably, make sure te01.a==te02.a and te01.b==te02.b). Depending on what you do with your objects, you would want to override Object.hashCode(), too.

Similar Messages

  • Question about java.lang.UnsatisfiedLinkError

    When I try connect to database using oci8 driver, I get this error. I try work with different driver versions 8.1.5, 8.1.7, java can't find different functions, but kind of error remain that same. Does anybody know, how fix this bug?
    PS
    Sorry about my ugly English.
    Thanks
    Max
    null

    Unsatsfied Link error means that the requiered libraries are not in the correct place. This is clearly mentioned in the documentation at : http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/java.817/a83724/getsta2.htm
    It depends on which OS you are using so I can not tell you... you will have to read and hopefully your probelm will be solved.
    By the way, I used the OCI and pure JDBC drivers on NT platform and found that pure driver gives better performance than oci driver, contrary to what many people say and it is written in the docs.
    It would be nice to know your experience with OCI driver.

  • Question about java.lang.long

    I have a very basic understanding problem:
    long a = (5*24*60*60*1000);
    long b = (30*24*60*60*1000);
    System.out.println(a);
    System.out.println(b);
    results in:
    [java] 432000000
    [java] -1702967296
    how can this be? I would expect the second one to be six times the first result, i.e. 2592000000
    I would highly appreciate any hints on what my misunderstanding is based on ...

    In the meantime I found it: Its in the language specification, $3.10.1 Integer Literals:
    An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise it is of type int (�4.2.1). The suffix L is preferred, because the letter l (ell) is often hard to distinguish from the digit 1 (one).

  • Question about "java.lang.ThreadLocal".

    public class PrinterUser extends Thread {
      private Printer printer;
      private String content;
      private String user;
      public PrinterUser(Printer printer,String content,String user) {
        this.printer = printer;
        this.content = content;
        this.user = user;
      void print() {
        printer.print(content);
      public void run() {
        print();
      public static void main(String[] args) {
        Printer p = new Printer();
        ThreadLocalPrinter tlp = new ThreadLocalPrinter();
        new PrinterUser(p,"User A is printing...","A").start();
        new PrinterUser(p,"User B is printing...","B").start();
        new PrinterUser(tlp,"User C is printing..." + tlp.get(),"C").start();
        new PrinterUser(tlp,"User D is printing..." + tlp.get(),"D").start();
    class Printer {
      synchronized void print(String content) {
        System.out.print("Preparing...");
        try {
          Thread.sleep(2000);
        catch(InterruptedException e) {
          System.out.println(e);
        System.out.println(content);
      synchronized void printErrors() {
        System.out.println("Errors...");
    class ThreadLocalPrinter extends Printer {
      private static int nextSerialNum = 0;
      private static ThreadLocal serialNum = new ThreadLocal() {
        protected synchronized Object initialValue() {
          return new Integer(nextSerialNum++);
      public static int get() {
        return ((Integer)serialNum.get()).intValue();
    }Why the result is :
    Preparing...Preparing...User A is printing...
    Preparing...User C is printing...0
    Preparing...User B is printing...
    User D is printing...0
    But not
    User C is printing...0
    User D is printing...1
    ?

    I seldom use ThreadLocal but a standard usage might be ...
    public class PrinterUser extends Thread {
      private ThreadLocalPrinter printer;
      private String content;
      private String user;
      public PrinterUser(ThreadLocalPrinter printer,String content,String user) {
        this.printer = printer;
        this.content = content;
        this.user = user;
      void print() {
        printer.print(content);
      public void run() {
        print();
      public static void main(String[] args) {
        ThreadLocalPrinter tlp = new ThreadLocalPrinter();
        PrinterUser puC = new PrinterUser(tlp, "User C is printing...", "C");
        PrinterUser puD = new PrinterUser(tlp, "User D is printing...", "D");
        puC.start();
        puD.start();
    abstract class Printer {
      synchronized void print(String content) {
        System.out.println("Preparing... " + getSerial());
        try {
          Thread.sleep(2000);
        catch(InterruptedException e) {
          System.out.println(e);
        System.out.println(content);
      abstract int getSerial();
      synchronized void printErrors() {
        System.out.println("Errors...");
    class ThreadLocalPrinter extends Printer {
      private static int nextSerialNum = 0;
      private static ThreadLocal serialNum = new ThreadLocal() {
        protected synchronized Object initialValue() {
          return new Integer(nextSerialNum++);
      public static int get() {
        return ((Integer)serialNum.get()).intValue();
      int getSerial(){
        return get();
    }

  • Question about "java.lang.Class.getConstructor(Class... parameterTypes)"

    Constructor<T> getConstructor(Class... parameterTypes)
    If i want to get the non-parameter Constructor?
    How can i do?

    Hint: varargs (Class...) can take any number of arguments, including zero.

  • Java/lang/NoClassDefFoundError: java/lang/Object

    Hi Experts,
    We are installing Java "1.6.0_31.We have updated the environment variables with the correct Java Path but which checking the java -version we are getting the following error.
    java -version
    Error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/Object
    hence the DAC service is not starting giving the following error.
    startserver.h: startserver.h: cannot open
    OS detected: SunOS
    ld.so.1: java: fatal: libjli.so: open failed: No such file or directory
    Killed
    Following are the environment variable entries.
    PATH=/opt/SUNWspro/bin:/../oracle/product/10.2.0/client_1/bin:/.../Informatica/PowerCenter8.6.1/server/bin:/usr/sfw/bin:/...../JAVA631/jdk1.6.0_31/bin/sparcv9:/.../JAVA631/jdk1.6.0_31/lib:/..../JAVA631/jdk1.6.0_31/jre/lib/sparcv9/jli:/...../JAVA631/jdk1.6.0_31/jre/lib/sparcv9:$PATH
    export PATH
    Need ur support.
    Thanks

    Where do you run shell script?
    What's your Oracle's version?
    What's text of your shell script?
    By asking 100 questions and keeping 90 of them "unanswered" you throw yourself to the list of "blacklist users"
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]
    Edited by: Kamran Agayev A. on May 19, 2009 1:28 PM

  • NoClassDefFound java/lang/Object error

    Hi all,
    I just tried to install JRE 1.4.1 on Win98 and encountered this error when I typed in java -version:
    error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/Object
    After I installed I added SET CLASSPATH = and the path to my rt.jar and tools.jar to my autoexec.bat, but that didn't seem to work.
    Sorry about posting this here if it isn't appropriate, I tried a forum search but kept getting Server Error.
    Steve

    Look at this thread:
    http://forum.java.sun.com/thread.jsp?forum=54&thread=106425
    Think it is reply 3 or 4, where you have to rename the the java.exe file somewhere in your system path

  • Weblogic - a web service with java.lang.Object parameter

    hi all,
    i'm creating a web service with a java.lang.Object parameter.
    my question is as follows:
    when a client calls the web service, how to i get the soap message object and convert it to soap message string using the parameter?
    thanks,
    alex

    Here's some code from one of the Axis samples, this shows the basic process of making a call:
    package samples.message;
    import org.apache.axis.client.Service;
    import org.apache.axis.client.Call;
    import org.apache.axis.message.SOAPBodyElement;
    import org.apache.axis.utils.Options;
    import org.apache.axis.utils.XMLUtils;
    import org.w3c.dom.Element;
    import java.net.URL;
    import java.util.Vector;
    public class TestMsg {
    public String doit(String[] args) throws Exception {
    Options opts = new Options(args);
    opts.setDefaultURL("http://localhost:8080/axis/services/MessageService");
    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress( new URL(opts.getURL()) );
    SOAPBodyElement[] input = new SOAPBodyElement[2];
    input[0] = new SOAPBodyElement(XMLUtils.StringToElement("urn:foo",
    "e1", "Hello"));
    input[1] = new SOAPBodyElement(XMLUtils.StringToElement("urn:foo",
    "e1", "World"));
    Vector elems = (Vector) call.invoke( input );
    SOAPBodyElement elem = null ;
    Element e = null ;
    elem = (SOAPBodyElement) elems.get(0);
    e = elem.getAsDOM();
    String str = "Res elem[0]=" + XMLUtils.ElementToString(e);
    elem = (SOAPBodyElement) elems.get(1);
    e = elem.getAsDOM();
    str = str + "Res elem[1]=" + XMLUtils.ElementToString(e);
    return( str );
    public static void main(String[] args) throws Exception {
    String res = (new TestMsg()).doit(args);
    System.out.println(res);

  • Question about Java's HttpServer: Threading? Backlog?

    Hello,
    I have two questions about Java's HttpServer (com.sun.net.httpserver). From the JavaDoc:
    >
    Management of threads can be done external to this object by providing a Executor object. If none is provided a default implementation is used.
    >
    How can I get information about the default implementation in 1.6.0_13? Do you know the behavior? From my observations, the default implementation uses no Threads, meaning every request is handled in the same Thread, this results in handling the requests to the HttpServer one after another.
    Is this right?
    The second question is about this, also from the JavaDoc:
    >
    When binding to an address and port number, the application can also specify an integer backlog parameter. This represents the maximum number of incoming TCP connections which the system will queue internally. [...]
    >
    When setting the backlog to -1, it uses the systems default backlog. How can I determine the systems default backlog? Can some lines of Java code reveal it (there is no getBeacklog() method)? Or is it up to the Operating System (we use Redhat Linux)?
    Thanks a lot for your help!
    Regards,
    Timo

    How can I determine the systems default backlog?You can't. There is no API for that even at the C level.
    Can some lines of Java code reveal itNo.
    Or is it up to the Operating System (we use Redhat Linux)?Yes. Linux provides a large default. It seems to be at least 50 on most platforms. This is not something you should be worrying about.

  • Help! How to convert an instance from java.lang.Object to a particula class

    * How to convert an instance from java.lang.Object class to a particular class
    witch is known only at the running time?
    Roster EJB component is make up of RosterHome, Roster and RosterBean.
    RosterHome is the home interface of Roster EJB.
    Roster is the remote interface of Roster EJB.
    RosterBean is the implement of Roster EJB.
    The following code segment is to invoke Roster EJB component.
    String jndiName="roster.RosterHome";
    javax.naming.Context initial = getInitialContext();//getInitialContext() returns a instance of Context.
    Object objref = initial.lookup(jndiName);
    RosterHome home =
    (RosterHome)javax.rmi.PortableRemoteObject.narrow(objref,
    RosterHome.class);
    Roster myRoster = home.create();
    String team="T1"
    String player="Tom"
    myRoster.addPlayer(player,team);
    But, now, all the home interface, the remote interface and the JNDI Name of
    Roster EJB component are not been known at the compiling time. However They are
    known at the running time, throught reading from the XML config file.
    Questions:
    1,How to write code for this case ? or
    2,How to convert an instance from Object class to a particular class witch is known
    only at the running time?
    String jndiName="roster.RosterHome";// in fact, reads from XML file.
    String homeClassName="roster.RosterHome";// in fact, reads from XML file.
    String remoteClassName="roster.Roster";// in fact, reads from XML file.
    javax.naming.Context initial = getInitialContext();//getInitialContext() returns a instance of Context.
    Object objref = initial.lookup(jndiName);
    Object objHome= javax.rmi.PortableRemoteObject.narrow(objref,
    Class.forName(homeClassName));
    /* how to do next?
    }

    I am not sure what you are trying to do. But at some point you should know which methods to call on the remote interfaces. Maybe the method names are stored in the XML file as well or you have a set of standard method names (also consider parameters).
    However, this can be solved by reflection. Look at the java.lang.reflect package, especially java.lang.reflect.Method, and also at java.lang.Class.
    If you are doing this on the app server:
    I've seen posts where people say that reflection is not permitted in EJB, but I don't think so. Check the EJB spec.
    If you are doing this in an application: reflection is always permitted. Probably also in applets and JSP.

  • Are there any problems to expect when srializing java.lang.Object?

    When having code like this:
    public class SomeClass implements Serializable{
    private final String NULL_CONSTANT="dmmystring";
    private Object result=new String(NULL_CONSTANT);
    ...whatever
    Class java.lang.Object is not implementing the Serializable Interface. In practise, this works fine however, I would like to understand this question. Will serialization work in every case as long as result is set to a serializable type?

    hi,
    If the object does not implement the Serilizable marker interface, then when you try to serialize the object, you will get a NotSerializableException. Also when you try to serialize a object, java will check to see if any variables contained in the object are also serializable and if so it serializes the same so in effect all attributes of the object must be either serializable or marked transient. When you mark a variable as transient, for eg
    transient Vector v;
    this object will not be serialized.
    you might want to check out the article at
    http://java.sun.com/docs/books/performance/1st_edition/html/JPIOPerformance.fm.html#11352
    It contains ways to improve serialization, but it will also be useful in understanding the Serialization concepts as such...
    hope this helpzz
    cheerz
    ynkrish

  • Error: initialization error: file java\lang\Object.class not found

    when the error listed my classpath's its not the same list that is in my Windows XP environment variable list?
    I am on 9.0.3
    I am assuming I have to set some varible to my new jdk\bin directory. I reinstalled it. I have set it to use jdk 1.4 using the ojvm tool a while back.

    Please help!!
    I did change the jdev.conf file setting:
    SetJavaHome /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home
    and I still get this error:
    initiallization erro: file java/lang/Object.class not found in classpath
    I am usgin Oracle JDeveloper 10g 10.1.2 on a Mac OS X Tiger
    Could someone please help?
    thanks a bunch!!!

  • Help with StuckThread in java.lang.String.equals(String.java:619)

    I periodically get a stuck Execute thread on my Weblogic 8.15 server
    during a call to a Stateless Session Bean. When I do thread dumps, the
    thread is always stuck in the same place (in
    java.lang.String.equals(String.java:619) or in the call immediately above it
    java.util.LinkedList.indexOf(LinkedList.java:397)). Even though the thread
    dump indicates that the thread is in a runnable state, if I do multiple
    thread dumps over a period of time, the stack trace always indicates that
    the thread is in the same place. The thread remains stuck until Weblogic is
    restarted. Other client applictions can make session bean calls, but each
    stuck thread seems to still take up lots of CPU time. I have let the stuck
    threads run overnight, and the stack trace from the thread dump always shows
    them executing the same String/LinkedList code. In each case, our code is
    trying to iterate over a collection
    Does anybody know what could cause this problem, and how to fix it? I get
    StuckThreadMaxTime errors in the log:
    ####<Dec 4, 2005 10:47:25 AM EST> <Error> <WebLogicServer> <nybill>
    <myserver> <weblogic.health.CoreHealthMonitor> <<WLS Kernel>> <>
    <BEA-000337> <ExecuteThread: '4' for queue: 'weblogic.kernel.Default' has
    been busy for "1,263" seconds working on the request
    "ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl", which
    is more than the configured time (StuckThreadMaxTime) of "1,200" seconds.>
    Here are some stack traces from different thread dumps (I have the full
    thread dumps if necessary):
    "ExecuteThread: '10' for queue: 'weblogic.kernel.Default'" daemon prio=5
    tid=0x7720eb98 nid=0xd68 runnable [571f000..571fdb0]
    at java.lang.String.equals(String.java:619)
    at java.util.LinkedList.indexOf(LinkedList.java:398)
    at java.util.LinkedList.contains(LinkedList.java:176)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getDailyCallSummary(XMLBillCr
    eation.java:1992)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getGraphs(XMLBillCreation.jav
    a:1931)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getLocations(XMLBillCreation.
    java:2618)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.createXMLBill(XMLBillCreation
    .java:236)
    at
    ncss.billing.ejb.billAdmin.session.BillAdminSessionEJB.getBillAsXml(BillAdmi
    nSessionEJB.java:341)
    at
    ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl.getBillAsX
    ml(BillAdminSession_uli3xb_EOImpl.java:100)
    at
    ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl_WLSkel.inv
    oke(Unknown Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
    :108)
    at
    weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
    at
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
    t.java:363)
    at
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
    at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
    0)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    "ExecuteThread: '22' for queue: 'weblogic.kernel.Default'" daemon prio=5
    tid=0x772538d0 nid=0xe24 runnable [497f000..4fdb0]
    at java.lang.String.equals(String.java:619)
    at java.util.LinkedList.indexOf(LinkedList.java:398)
    at java.util.LinkedList.contains(LinkedList.java:176)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getMostExpensiveOrLongestCall
    s(XMLBillCreation.java:1892)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getTopTenReport(XMLBillCreati
    on.java:1798)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getTopTenReports(XMLBillCreat
    ion.java:1751)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getLocations(XMLBillCreation.
    java:2612)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.createXMLBill(XMLBillCreation
    .java:236)
    at
    ncss.billing.ejb.billAdmin.session.BillAdminSessionEJB.getBillAsXml(BillAdmi
    nSessionEJB.java:341)
    at
    ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl.getBillAsX
    ml(BillAdminSession_uli3xb_EOIm.java:100)
    at
    ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl_WLSkel.inv
    oke(Unknown Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
    :108)
    at
    weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
    at
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
    t.java:363)
    at
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
    at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
    0)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    "ExecuteThread: '21' for queue: 'weblogic.kernel.Default'" daemon prio=5
    tid=0x76afb060 nid=0x498 runnable [48af000..48fdb0]
    at java.lang.String.equals(String.java:619)
    at java.util.LinkedList.indexOf(LinkedList.java:398)
    at java.util.LinkedList.contains(LinkedList.java:176)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getMostFrequentlyCalledNumber
    sOrCitiesReport(XMLBillCreation.java:1839)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getTopTenReport(XMLBillCreati
    on.java:1772)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getTopTenReports(XMLBillCreat
    ion.java:1743)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.getLocations(XMLBillCreation.
    java:2612)
    at
    ncss.billing.broadviewBill.xml.XMLBillCreation.createXMLBill(XMLBillCreation
    .java:236)
    at
    ncss.billing.ejb.billAdmin.session.BillAdminSessionEJB.getBillAsXml(BillAdmi
    nSessionEJB.java:341)
    at
    ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl.getBillAsX
    ml(BillAdminSession_uli3xb_EOImp.java:100)
    at
    ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl_WLSkel.inv
    oke(Unknown Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
    :108)
    at
    weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
    at
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
    t.java:363)
    at
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
    at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
    0)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    The code in LinkedList that it seems to be executing is the following:
    Line#
    397 for (Entry e = header.next; e != header; e = e.next) {
    398 if (o.equals(e.element))
    399 return index;
    400 index++;
    401 }
    I am running Weblogic 8.15 on Windows 2000.
    Thanks for any help,
    - Don

    njb7ty wrote:
    I suggest dropping that example program and concentrating on reading a book on Java such as 'Head First in Java'. Otherwise, you will spend a lot of time trying to get something to work and gain little value from it.Likewise... Jumping into reflections before you can [read a stack-trace|http://www.0xcafefeed.com/2004/06/of-thread-dumps-and-stack-traces/] is like signing up a toddler for the New York Marathon... it's probably simply beyond your skill level... so step back... go read a book, do some tutorials, get your head around just the process of the designing, writing, compiling, running, and debugging java programs... and what the different diagnostics mean... Then, equipped with your nose-clip and your trusty stone ;-) you contemplate leaping into the deep end ;-)
    Cheers. Keith.

  • Error: invalid file 'java/lang/Object.class' (wrong version: 48, expected 4

    hi all
    ive installed jdk1.4.1 from jdk1.3 .
    When i try to compile a java file i get this error.
    Error: invalid file 'java/lang/Object.class' (wrong version: 48, expected 45)
    anyone has any idea abt this.
    im stuck :( pls help.
    thanks
    Jan

    Did you uninstall 1.3 completely? Completely in the sense both jdk and jre.
    You may get this error if you use javac of one version and the rt.jar of another version.
    Sudha

  • Sort(java.util.LinkedList java.lang.Object ) doesn't work

    Why doesn't this work?
    LinkedList<Object> sysPropsKeys = new LinkedList<Object>(System.getProperties().keySet());
    Collections.sort(sysPropsKeys);
    cannot fnd symbol
    symbol : method sort(java.util.LinkedList<java.lang.Object>)
    location: class java.util.Collections

    I will admit to not having Java1.5 installed on my machine. Haven't yet had the chance to play with generics, but the above DOES work in 1.4, and SHOULD work in 1.5
    Maybe I'm naive but, System.getProperties() returns a Properties object right?
    According to the API: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html: Each key and its corresponding value in the property list is a string.
    All the keys SHOULD be strings.
    AFAIK string are comparable, and shouldn't throw class cast exceptions
    Thus the keys returned from getProperties SHOULD be comparable, and compatible for comparision.
    Ok, I can see your point in that some hackers abuse the Properties class by putting non string keys/values into the Properties Map. In that case the code would become more like your above. I'd probably still go with a TreeMap though, rather than a sorted list of keys. Most time you want the keys, you want the values as well. So if the intention is to print out a sorted list of system properties, and their values, keeping it in a map is best.
    Just my 2 cents,
    evnafets

Maybe you are looking for

  • Deploying Shared Variables to Remote Target?

    I have a 2-application server/client setup where my client(s) merely read information "published" by the server via a Network-Shared Shared Variable.  If I run my server on a "clean machine" (i.e. no LabVIEW development) and I "publish" the shared va

  • Downloading songs from a different computer with out reformatting my i pod

    Hey there, it's probably a common question. Is there any way to download songs from a different computer with out having to reformat the ipod and lose all my songs i have on there. I've tried it once and it wiped my ipod clean of all my songs. Very a

  • Splitting music files between internal and external HDs

    I have a 300Gb external hard drive that I primarily use for storage/backup of rarely accessed files. I have seen a number of topics about moving your entire library to an external drive, but that's not what I want. I leave my external drive at home w

  • MS Office Research JAXRPC web service disconnect

    I'm trying to create a custom MS Office Research service using JAXRPC in jwsdp1.6. I've got my service returning a Registration response that looks structurally/semantically equivalent to that of the sample Google service. However MS Word is rejectin

  • ( SOLVED )gnome-terminal, su, sudo, gksu, gksudo does not work

    Hello, In my fresh installed gnome3 graphical environment, in gnome-terminal, I can not gain root access. I've tried diverse su commands. 1. su command, ends with: su - Password: su: Authentication failure 2. sudo command, ends with: sudo -l [sudo] p