My program makes 5 instances of a class; Why?

I removed or commented out as much as possible.
I still get five instances of the RecordObj class. There are five methods in that class, other than the getters and setters, so I suspect the problem involves those methods, but I don't know how a method (that is not called) could cause its containing class to be instantiated. Does anybody see what I can't?
recordObj_ (static)= 0
recordObj_ before making Connection = 1
recordObj_ after making Connection = 1
recordObj_ before making Connection = 2
recordObj_ after making Connection = 2
recordObj_ before making Connection = 3
recordObj_ after making Connection = 3
recordObj_ before making Connection = 4
recordObj_ after making Connection = 4
recordObj_ before making Connection = 5
recordObj_ after making Connection = 5
arr.length = 4
and here are the calling class and the class being called:import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import hw5Corba.*;
public class RecordServer2
  static Record[] arr;
  public static void main(String args[])
      RecordObj impl = new RecordObj();
      arr = impl.getRecords();
      System.out.println("arr.length = "+arr.length);
import java.sql.*;
import hw5Corba.*;
public class RecordObj extends _RecordImplBase
  static Connection connection = null;
  ResultSet rs;
  private String
    user = null,
    firstName =null,
    lastName=null,
    streetAddress=null,
    city=null,
    country=null,
    eMail=null,
    phone=null,
    fax=null;
  static int recordObj_ =0;
  private int recordNumber;
  static
    System.out.println("recordObj_ (static)= "+recordObj_+"\n\n");
  public RecordObj()
    recordObj_++;
   System.out.println("recordObj_ before making Connection = "+ recordObj_);
   connection = SingletonDBConnector.getInstance().getConnection();
    //RecordServerGui gui = new RecordServerGui(connection);
    System.out.println("recordObj_ after making Connection  = "+ recordObj_);
  public void user(String param)
    user = param;
  public void setUser(String param)
    user(param);
  public String user()
    return user;
  public String getUser()
    return user();
  public void recordNumber(int recNum)
    recordNumber = recNum;
  public void setRecordNumber(int recNumber)
    recordNumber(recNumber);
  public int recordNumber()
    return recordNumber();
  public int getRecordNumber()
    return recordNumber();
  public void firstName(String first)
    firstName =first;
  public void setFirstName(String first)
    firstName(first);
  public String firstName()
    return firstName;
  public String getFirstName()
    return firstName();
  public void lastName(String last)
    lastName = last;
  public void setLastName(String last)
    lastName(last);
  public String lastName()
    return lastName;
  public String getLastName()
    return lastName();
  public void streetAddress(String add)
    this.streetAddress = add;
  public void setStreetAddr(String add)
    streetAddress(add);
  public String streetAddress()
    return streetAddress;
  public String getStreetAddr()
    return streetAddress();
  public void city(String city)
    this.city = city;
  public void setCity(String _city)
    city(_city);
  public String city()
    return city;
  public String getCity()
    return city();
  public void country(String country)
    this.country = country;
  public void setCountry(String _country)
    country(_country);
  public String country()
    return country;
  public String getCountry()
    return country();
  public void eMail(String email)
    this.eMail = email;
  public void setEmail(String _email)
    eMail(_email);
  public String eMail()
    return eMail;
  public String getEmail()
    return eMail();
  public void phone(String phone)
    this.phone = phone;
  public void setPhone(String _phone)
    phone(_phone);
  public String phone()
    return phone;
  public String getPhone()
    return phone();
  public void fax(String fax)
    this.fax = fax;
  public void setFax(String _fax)
    fax(_fax);
  public String fax()
    return fax;
  public String getFax()
    return fax();
  public Record[] getRecords()
    Record r = null;
    Record[] allRecs = null;
    int index = 0;
    String selectAll = "SELECT * FROM Record ORDER BY Record_number";
    try
      Statement s = connection.createStatement();
      ResultSet recs = s.executeQuery(selectAll);
      while(recs.next())
        index++;
      allRecs = new Record[index];
      //cycle through records again, adding each
      //to the array
      index = 0;
      recs = s.executeQuery(selectAll);
      while(recs.next())
        r = new RecordObj();
        r.setRecordNumber(recs.getInt(1));
        r.setFirstName(recs.getString(2));
        r.setLastName(recs.getString(3));
        r.setStreetAddr(recs.getString(4));
        r.setCity(recs.getString(5));
        r.setCountry(recs.getString(6));
        r.setEmail(recs.getString(7));
        r.setPhone(recs.getString(8));
        r.setFax(recs.getString(9));
        allRecs[index] = r;
      catch (SQLException ex)
        exceptionCode(ex);
    return allRecs;
  public void deleteRecord(int num)
    //SQL for Records table
    String command =
    "DELETE FROM Record WHERE Record_number ="
      + Integer.toString(num);
    //SQL for UserLog table
    String timeOn = new java.util.Date().toString();
    String logCommand ="INSERT INTO UserLog VALUES(?,?,?)";
    try
      //Records table
      PreparedStatement delRec = connection.prepareStatement(command);
      int rowsUpdated = delRec.executeUpdate();
      System.out.println("rows affectd by delRecord " + rowsUpdated);
      //UserLog table
      PreparedStatement logSt = connection.prepareStatement(logCommand);
      logSt.setString(1,user);
      logSt.setString(2,timeOn);
      logSt.setString(3,command);
      int logRowsUpdated = logSt.executeUpdate();
     catch (SQLException ex)
       exceptionCode(ex);
  public void newRecord(Record r)
    //SQL for Records table
    String prefix ="INSERT INTO Record VALUES";
    String suffix = "(?,?,?,?,?,?,?,?,?)";
    //SQL for UserLog table
    String timeOn = new java.util.Date().toString();
    String action = prefix + "(" + r.getRecordNumber()+ ", "
    + r.getFirstName()+ ", " + r.getLastName()+ ", "
    + r.getStreetAddr()+ ", " +r.getCity()+ ", "
    + r.getCountry()+ ", " +r.getEmail()+ ", "
    + r.getPhone()+ ", " +r.getFax()+")";
    String command ="INSERT INTO UserLog VALUES(?,?,?)";
    try
      PreparedStatement newRec = connection.prepareStatement(prefix + suffix);
      newRec.setInt(1,r.getRecordNumber());
      newRec.setString(2,r.getFirstName());
      newRec.setString(3,r.getLastName());
      newRec.setString(4,r.getStreetAddr());
      newRec.setString(5,r.getCity());
      newRec.setString(6,r.getCountry());
      newRec.setString(7,r.getEmail());
      newRec.setString(8,r.getPhone());
      newRec.setString(9,r.getFax());
      int rowsUpdated = newRec.executeUpdate();
      System.out.println("rows affectd by newRecord " + rowsUpdated);
      PreparedStatement logSt = connection.prepareStatement(command);
      logSt.setString(1,user);
      logSt.setString(2,timeOn);
      logSt.setString(3,action);
      int logRowsUpdated = logSt.executeUpdate();
      System.out.println("rows affectd by logging " + logRowsUpdated);
    catch (SQLException ex)
      exceptionCode(ex);
  public void updateRecord(Record r)
    //SQL for Records table
    String command =
    "UPDATE Record SET FirstName = '"+ r.getFirstName()
      + "', LastName = '"+r.getLastName()
      + "', StreetAddress = '"+ r.getStreetAddr()
      + "', City = '"+ r.getCity()
      + "', Country = '"+ r.getCountry()
      + "', email = '"+ r.getEmail()
      + "', phone = "+ r.getPhone()
      +", fax = "+ r.getFax()
   + " WHERE Record_Number = "+ r.getRecordNumber();
    String timeOn = new java.util.Date().toString();
    String action ="INSERT INTO UserLog VALUES(?,?,?)";
    try
      //Records table
      Statement updateRec = connection.createStatement();
      int rowsUpdated = updateRec.executeUpdate(command);
      //UserLog table
      PreparedStatement logSt = connection.prepareStatement(action);
      logSt.setString(1,user);
      logSt.setString(2,timeOn);
      logSt.setString(3,command);
      int logRowsUpdated = logSt.executeUpdate();
      System.out.println("rows affected by updateRecord " + rowsUpdated);
    catch (SQLException ex)
     exceptionCode(ex);
  public String[] getColumnNames()
    String command = "SELECT * FROM Record";
    String[] names = null;
/*    try
      Statement s = connection.createStatement();
      ResultSet recs = s.executeQuery(command);
      ResultSetMetaData rsmd = recs.getMetaData();
      int numCols = rsmd.getColumnCount();
      names = new String[numCols];
      for(int i=1;i<=rsmd.getColumnCount();i++)
        names[i-1] = rsmd.getColumnLabel(i);
    catch (SQLException ex)
      exceptionCode(ex);
     return names;
  public void exceptionCode(SQLException ex)
    System.out.println ("SQLException:");
    while (ex != null)
      System.out.println ("SQLState: "
         + ex.getSQLState());
      System.out.println ("Message:  "
         + ex.getMessage());
      System.out.println ("Vendor:   "
         + ex.getErrorCode());
      ex = ex.getNextException();
      System.out.println ("");
}

I think I found it, as usual right after a long struggle followed by a post.

Similar Messages

  • Calling instance method from an instance of a class.

    Hi,
    Can anyone tell me How can i change this TestAccount0 class so that i get the balance from Account class.
    public class TestAccount0
       public static void main(String[] args) {
         Account.deposit(1000);
         System.out.println(Account.getBalance());
    }I have done it this way. I just want to print the balance without* saving the instance of the Account class in any variable in the 1st statement. Can i do it this way?. I have made instance of Account class to access deposit method but how can i print whatever is in the first statement? What can i do to print 1000 as says in the 1st statement because apparently it is printing balance 0.
    Thanks
    public class TestAccount0
       public static void main(String[] args) {
                 (new Account()).deposit(1000);//make instance of Account class to access the method of Account class.
                 System.out.println((new Account()).getBalance());// prints the balance which in this case would be 1000.
    }

    Jas85 wrote:
    So the original code doesn't read Account.deposit(1000) at all?
    I think you can make that work by writing instance of class I.e (new Account()).deposit(1000).(a) please answer the question
    (b) Not unless you want to throw away the Account, and its balance, immediately. Which doesn't make sense, does it?
    Alternatively the original code doesn't look like that at all ...
    ok...you are saying they have given me the wrong code to fix.No, I am saying that either the original code doesn't look like what you posted here, or they have given you an impossible assignment. It should look like this:
    Account ac = new Account();
    ac.deposit(1000);
    System.out.println("balance="+ac.getBalance());

  • Can't make a selection of my pathes even if i have set a program change number for each one.Why is that happening?

    Hi everybody!
    I send program change messages from my midi controller and the messages are accepted by mainstage 3 as shown in the midi message window,but i can't make a selection of my pathes even if i have set a program change number for each patch.Why is that happening?
    I use a novation SL mki or a KORG Triton Le or a m-audio axiom 49 as midi controllers.The program change messages are transmitted by all the devices i mentioned above and shown as received in the midi messages window of mainstage 3.
    Has anyone the same experience?

    Hi
    Have you selected the correct device as the Program Change device and MIDI channel in the Concert Inspector?
    CCT

  • How do I make an instance of another class??

    How do I make an instance of a class, (eg. the name of the class is oldJava.class and have a constructor that takes 3 parameters)in a new class. and send paramaters to the oldJava.class constructor. I also want to recive the result from oldJava.class in my new class.
    ??I would be really glad if I could get some code example.....
    //HA

    oldJava o = new oldJava(..., ..., ...); // your arguments here
    o.method1(); // you can call methods on this object now
    // If the method returns anything back, you can keep a reference to it
    int result = o.sum(2, 5);

  • Creating multiple instances of a class in LabVIEW object-oriented programming

    How do you create multiple instances of a class in a loop?  Or am I thinking about this all wrong?
    For instance, I read in a file containing this information:
    Person Name #1
    Person Age #1
    Hobby #1
    Hobby #2
    Hobby #3
    Person Name #2
    Person Age #2
    Hobby #1
    Hobby #2
    Hobby #3
    Person Name #3
    Person Age #3
    Hobby #1
    Hobby #2
    Hobby #3
    If I define a Person class with name, age, and an array of strings (for the hobbies), how can I create several new Person instances in a loop while reading through the text file?
    FYI, new to LabVIEW OOP but familiar with Java OOP.  Thank you!

    First of all, let's get your terminology correct.  You are not creating multiple instances of a class.  You are creating Objects of the class.
    Use autoindexing to create an array of your class type.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to create the instance of a class and to use this object remotely

    I have to change a standalone program to do it working on a local net.
    the program is prepared for this adjustment, because the only problem for this change came from the use of the database; and, in the application, all the accesses to the database come from only a class that supplies a connection to the database.
    In this way I think that I could have (in a local net) a "server application" that has the database embedded inside it.
    Furthermore, some client applications (running in different computers of the net) could get access to the database through the connection that comes from an instance of the class that, in the "server application", is made to provide the connection to the database.
    I think this could be a good idea...
    But I don't have practice with distributed applications and I would ask some suggestion about the way to realize my modification.
    (in particular how to get and use, in the "client applications", the instance of the class that give the connection to the database from the "server application").
    I would have some help..
    thank in advance
    regards
    tonyMrsangelo.

    tonyMrsangelo wrote:
    I have to change a standalone program to do it working on a local net.
    the program is prepared for this adjustment, because the only problem for this change came from the use of the database; and, in the application, all the accesses to the database come from only a class that supplies a connection to the database.
    In this way I think that I could have (in a local net) a "server application" that has the database embedded inside it.
    Furthermore, some client applications (running in different computers of the net) could get access to the database through the connection that comes from an instance of the class that, in the "server application", is made to provide the connection to the database.
    I think this could be a good idea... Which is why JEE and implementations of that exist.
    But I don't have practice with distributed applications and I would ask some suggestion about the way to realize my modification.
    (in particular how to get and use, in the "client applications", the instance of the class that give the connection to the database from the "server application").
    You can't pass a connection from a server to a client. Nothing will do that.
    As suggested you can create a simple RMI server/client set up. Or use a more feature rich (and much more complex) JEE container.
    RMI is simple enough for its own tutorial
    [http://java.sun.com/docs/books/tutorial/rmi/index.html]
    JEE (previously called J2EE) is much more complex and requires books. You can get a brief overlook from the following
    [http://java.sun.com/javaee/]

  • I want to run single instance of my class ?

    i have a class with name Abc, i want when my Abc class is
    in running mode then i cant run my Abc class again untill my
    Abc class not exit.
    i want to do that in pure java, i have one logic but it is not
    proper salution.
    my logic is that when my programe is start first check a temprery file
    which is created by my programe and when i want to exit then i delete
    that temprery file.
    but if computer is shutdown unproperly and my programe is in running mode then my file is not delete.
    please any body give me help.
    i m thanksfull.
    Arif.

    Hi,
    let's make it more precise as so "if my class is in running mode" is not very precise - I guess, you are not talking of a class which has implemented the Runnable interface and is executed via "new Thread(Abc).start()". I think, you want a class, which can only have one instance of it at a time, right?
    It is no problem, to make a class, which has only one instance - it is called a Singleton class - it consists of the following:
    public class MySingleton extends Object // or any other class
    public static final instance = new MySingleton();
    //the trick here is to declare its constructor private
    private MySingleton() { super(); }
    // some other methods here
    }There is only one instance of this class accessible via MySingleton.instance. The problem with it is, that it doesn't match your requirements, as so you are not able to instantiate this class ever again, even so you would declare the "instance" field not final and set it to null.
    What you can do now is dealing with security managers - check the documentation of the newInstance() method of the Class class and the SecurityManager class, there you will find several links to documentation related with the use of an security manager.
    greetings Marsian
    P.S.: all these *** in the text are the letters a s s :(

  • How can I make server use single class loader for several applications

    I have several web/ejb applications. These applications use some common libraries and should share instances of classes from those libraries.
    But applications are being deployed independently thus packaging all them to EAR is not acceptable.
    I suppose the problem is that each application uses separate class loader.
    How can I make AS use single class loader for a set of applications?
    Different applications depend on different libraries so I need a way that will not share library for all applications on the domain but only for some exact applications.
    When I placed common jar to *%domain%/lib* - all works. But that jar is shared between all applications on the domain.
    When I tried to place common jar to *%domain%/lib/applibs* and specified --libraries* attribute on deploying I got exception
    java.lang.ClassCastException: a.FirstDao cannot be cast to a.FirstDaoHere http://download.oracle.com/docs/cd/E19879-01/820-4336/6nfqd2b1t/index.html I read:
    If multiple applications or modules refer to the same libraries, classes in those libraries are automatically shared.
    This can reduce the memory footprint and allow sharing of static information.Does it mean that classes should be able to be casted ?

    You didn't specify which version of the application server you are using, but the config is similar as long as you know what to look for. Basically, you need to change the classloader delegation. Here's how it is done in 8.2
    http://download.oracle.com/docs/cd/E19830-01/819-4721/beagb/index.html

  • How to call a instance method without creating the instance of a class

    class ...EXCH_PRD_VERT_NN_MODEL definition
    public section.
      methods CONSTRUCTOR
        importing
          value(I_ALV_RECORDS) type ..../EXCH_VBEL_TT_ALV
          value(I_HEADER) type EDIDC .
      methods QUERY
        importing
          I_IDEX type FLAG
          i_..........
        returning
          value(R_RESULTS) type .../EXCH_VBEL_TT_ALV .
    Both methods are instance methods.
    But in my program i cannot created instance of the class unless i get the results from Query.
    I proposed that Query must be static, and once we get results we can create object of the class by pasing the result table which we get from method query.
    But i must not change the method Query to a static method.
    Is there any way out other than making method Query as static ?
    Regards.

    You can't execute any instance method without creating instance of the class.
    In your scenario, if you don't want to process your method of your class, you can check the instance has been created or not.
    Like:
    IF IT_QUERY IS NOT INITIAL.
      CRATE OBJECT O_QUERY EXPORTING......
    ENDIF.
    IF O_QUERY IS NOT INITIAL.
    CALL METHOD O_QUERY->QUERY EXPORTING....
    ENDIF.
    Regards,
    Naimesh Patel

  • Create multiple instances of same class but with unique names

    Hi,
    I'm creating an IM application in Java.
    So far I can click on a user and create a chat session, using my chatWindow class. But this means I can only create one chatWindow class, called 'chat'. How can I get the application to dynamically make new instances of this class with unique names, for examples chatWindowUser1, chatWindowUser2.
    Below is some code utlising the Openfire Smack API but hopefully the principle is the clear.
        private void chatButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
            int selectedUserIndex = rosterList.getSelectedIndex();
            String selectedUser = rostAry[selectedUserIndex].getUser();
            System.out.println("Chat with: " + selectedUser);
            if (chatBox == null) {
                JFrame mainFrame = CommsTestApp.getApplication().getMainFrame();
                chatBox = new CommsTestChatBox(mainFrame,conn,selectedUser);
                chatBox.setLocationRelativeTo(mainFrame);
            CommsTestApp.getApplication().show(chatBox);
    }  

    yes, an array would work fine, just realize that by using an array, you're setting an upper bound on the number of windows you can have open.
    As for unique names, if you mean unique variable name, you don't need one. The array index serves to uniquely identify each instance. If you mean unique title for the window, set that however you want (username, index in array, randomly generated string, etc.). It's just a property of the window object.

  • Create an instance of my class variable

    Hello all,
    I'm a newbie to iPhone/iPad programming and am having some trouble, I believe the issue is that I'm not creating an instance of my class variable.  I've got a class that has a setter and a getter, I know about properties but am using setters and getters for the time being.  I've created this class in a View-based application, when I build the program in XCode 3.2.6 everything builds fine.  When I step through the code with the debugger there are no errors but the setters are not storing any values and thus the getters are always returning 0 (it's returning an int value).  I've produced some of the code involved and I was hoping someone could point out to me where my issue is, and if I'm correct about not instantiating my variable, where I should do that.  Thanks so much in advance.
    <p>
    Selection.h
    @interface Selection : NSObject {
      int _choice;
    //Getters
    -(int) Choice;
    //Setters
    -(void) setChoice:(int) input;
    Selection.m
    #import "Selection.h"
    @implementation Selection
    //Getters
    -(int)Choice {
      return _choice;
    //Setter
    -(void)setChoice:(int)input{
              _choice = input;
    RockPaperScissorsViewController.m
    #import "RockPaperScissorsViewController.h"
    @implementation RockPaperScissorsViewController
    @synthesize rockButton, paperButton, scissorsButton, label;
    //@synthesize humanChoice, computerChoice;
    -(void)SetLabel:(NSString *)selection{
              label.text = selection;
    -(IBAction)rockButtonSelected {
    //          [self SetLabel:@"Rock"];
              [humanChoice setChoice:1];
    </p>
    So in the above code it's the [humanChoice setChoice:1] that is not working.  When I step through that portion with the debugger I get no errors but when I call humanChoice.Choice later on in the code I get a zero.
    -NifflerX

    It worked, thank you so much.  I put
    humanChoice = [[Selection alloc]init];
    In viewDidLoad and it worked like a charm.  Thank you again.
    -NifflerX

  • [JS, CS4] TextFrame.extractLabel() cannot work with instances of this class

    I have script, which has been working fine in CS3. In CS4 ( app.version = 6.0.1.532 ) however, I get an error using extractLabel, after reading out a couple of other properties from a textframe:
    frameObject.extractLabel('name')
    Error: TextFrame.extractLabel() cannot work with instances of this class
    Up until reading one of the "normal" properties, such as (frameObject.)contents I can call the frameObject.extractLabel('name') without errors, but after "looking at" (by assigning to a variable in code, or by getting the value in the javascript console), the contents propery (or as it seems any normal property) the extractLabel method results in the error above.
    It seems to work to move all of the frameObject.extractLabel calls to the beginning of the function, but I don't think I should need to do that.
    It might very well be the case that the label read by extractLabel has no contents, and has never been assigned. Is there a change in behaviour from CS3 in that sentence? If so, and if thats the reason for the error, is there then a way to determine whether the label has ever been assigned?
    Is this error familiar to anyone else?
    Best regards,
    Andreas

    Hi Andreas,
    Interesting problem!
    Your problems are caused by some peculiarities of itemByID. itemByID doesn't cast the object type properly. Dirk wrote about some aspects of this some time ago. If the scripting engine was strongly typed, this issue would probably be impossible but that would make scripting a lot more of an elitist activity!
    Your problem is that the object type is PageItem and you are accessing a TextFrame property (content). This seems to throw the object type for a loop.
    Using getElements() causes the scripting engine to rebuild the reference to the object correctly.
    Take a look at this code, which illustrates the issue quite well...
    var myDocument = app.documents.add();
    myDocument = app.activeDocument;
    myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
    myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
    var myTextFrame = myDocument.pages.item(0).textFrames.add({geometricBounds:[72, 72, 144, 288], contents:"test"});
    var myId = myTextFrame.id;
    var pgItm = myDocument.pageItems.itemByID(myId);
    alert(pgItm instanceof PageItem);
    alert(pgItm instanceof TextFrame);
    var thisBounds = pgItm.geometricBounds;
    var x = pgItm.extractLabel('mandatory');
    var pgItm = myDocument.textFrames.itemByID(myId);
    alert(pgItm instanceof PageItem);
    alert(pgItm instanceof TextFrame);
    var thisName = pgItm.extractLabel('name');
    var thisContents = pgItm.contents;
    var x = pgItm.extractLabel('mandatory');
    Harbs

  • How do i create a single instance of a class inside a servlet ?

    how do i create a single instance of a class inside a servlet ?
    public void doGet(HttpServletRequest request,HttpServletResponseresponse) throws ServletException, IOException {
    // call a class here. this class should create only single instance, //though we know servlet are multithreaded. if, at any time 10 user comes //and access this servlet still there would one and only one instance of //that class.
    How do i make my class ? class is supposed to write some info to text file.

    i have a class MyClass. this class creates a thread.
    i just want to run MyClass only once in my servlet. i am afriad, if there are 10 users access this servlet ,then 10 Myclass instance wouldbe created. i just want to avoid this. i want to make only one instance of this class.
    How do i do ?
    they have this code in the link you provided.
    public class SingletonObject
      private SingletonObject()
        // no code req'd
      public static SingletonObject getSingletonObject()
        if (ref == null)
            // it's ok, we can call this constructor
            ref = new SingletonObject();          
        return ref;
      public Object clone()
         throws CloneNotSupportedException
        throw new CloneNotSupportedException();
        // that'll teach 'em
      private static SingletonObject ref;
    }i see, they are using clone !, i dont need this. do i ? shouldi delete that method ?
    where do i put my thread's run method in this snippet ?

  • What is the difference between instance variable and class variable?

    i've looked it up on a few pages and i'm still struggling a bit maybe one of you guys could "dumb" it down for me or give and example of how their uses differ.
    thanks a lot

    Instance is variable, class is an object.What? "Instance" doesn't necessarily refer to variables, and although it's true that instances of Class are objects, it's not clear if that's what you meant, or how it's relevant.
    if you declare one instance in a class that instance
    should be sharing within that class only.Sharing with what? Non-static fields are not shared at all. Sharing which instance? What are you talking about?
    if you declare one class object it will share
    anywhere in the current program.Err...you can create global variables in Java, more or less, by making them static fields. If that's what you meant. It's not a very good practice though.
    Static fields, methods, and classes are not necessarily object types. One can have a static primitive field.

  • How to create an instance of a class?

    how do you create sn instance of a class, and how do you call a method from another class?

    You may need to read thru the information provided on this page to understand how to create objects: http://java.sun.com/docs/books/tutorial/java/data/objectcreation.html
    I'd also suggest you read the tutorial available at: http://java.sun.com/docs/books/tutorial/java/index.html
    Regarding how you call a method belonging to another class you could do it in the foll. ways depending on whether the method is static or not - a static method may be called using the class name followed by a dot and the static method name while a non-static method would require you to create an instance of the class and then use that instance name followed by a dot and the method name. All said and done i'd still suggest you read thru the complete Java programming tutorial to get a good grounding on all these concepts and fundamentals of the language if you are looking to master the technology.
    Thanks
    John Morrison

Maybe you are looking for

  • Custom Report taking more time to complete Normat

    Hi All, Custom report(Aging Report) in oracle is taking more time to complete Normal. In one instance, the same report is taking 5 min and the other instance this is taking 40-50 min to complete. We have enabled the trace and checked the trace file,

  • How do I build a simple MP3 player in Flash?

    I have recently redesigned my website and need to make several mp3 files available for playback. I'm a voiceover talent, and I need to have my demos readily available to those who visit my website to hear my work. I built the site using Dreamweaver (

  • Want A query (Its Urgent)

    Hi,I have a table as below.. AFPFTRAN code date type amt 12 10-04-05 T 1 13 11-05-05 F 2 12 10-05-05 T 3 13 05-04-05 F 4 12 12-04-05 T 5 13 15-05-05 F 7 I want details as below: date Apr May --- code T F T F --- 12 6 0 3 0 13 0 4 0 9 I want to get su

  • Host string and new users

    Hi, I've just installed DevSuiteHome1, OraDb10g_home1, and Oracle Developer Suite - DevSuiteHome1 and will be creating forms for an assignment. I've managed to log in to SQL*Plus with: "/ as sysdba" and successfully created a new user with a password

  • TS3694 error 3194 in itunes when trying to restore iphone?

    My iPhone 4S is stuck in recovery mode which occured whilst I was trying to update it today.  iTunes no longer recognises the phone and only says that it has detected a phone in recovery mode and needs to be restored before it can be used with iTunes