Instance of Class

Hey everyone,
I have declared an instance of a class Staffmember (stafflist = new StaffMember[n]) which holds the name, address, phone number and whether they are full time of part time. These arguments all get passed in as strings into the constructor except for the last argument which is a boolean value.
My question is how do I write a block of code that will check to see if lets say employee Staffmember[i] is full time or part time? And likewise how would I check to see if Staffmember[i] is say "Bill"?
Thanks!

if (employee.isPartTime())

Similar Messages

  • How to get instance of Class with its type parameters

    Hi,
    Have any of you folks been dealing with generics long enough to show me how this should be written? Or point me to the answer (I have searched as well as I could).
    I boiled down my situation to the included sample code, which is long only because of the inserted comments. And while boiling I accidentally came across a surprise solution (a bug?), but would obviously prefer a smoother solution.
    My Questions (referred to in the code comments):
    #1. Is there a way to get my parameterized type (classarg) without resorting to using the bogus (proto) object?
    #2. Can anyone understand why the "C" and "D" attempts are different? (All I did was use an intermediate variable????) Is this a bug?
    Thanks so much for any input.
    /Mel
    class GenericWeird
       /* a generic class -- just an example */
       static class CompoundObject<T1,T2>
          CompoundObject(T1 primaryObject, T2 secondaryObject)
       /* another generic class -- its main point is that its constr requires its type class */
       static class TypedThing<ValueType>
          TypedThing(Class<ValueType> valuetypeclass)
       // here I just try to create a couple of TypedThings
       public static void main(String[] args)
          // take it for granted that I need to instantiate these two objects:
          TypedThing<String>                        stringTypedThing = null;
          TypedThing<CompoundObject<String,String>> stringstringTypedThing = null;
          // To instantiate stringTypedThing is easy...
          stringTypedThing = new TypedThing<String>(String.class);
          // ...but to instantiate stringstringTypedThing is more difficult to call the constructor
          Class<CompoundObject<String,String>> classarg = null;
          // classarg has got to be declared to this type
          //    otherwise there will rightfully be compiler error about the constructor call below
          // This method body illustrates my questions
          classarg = exploringHowToGetTheArg();
          // the constructor call
          stringstringTypedThing = new TypedThing<CompoundObject<String,String>>(classarg);
       } // end main method
       // try compiling this method with only one of A,B,C,D sections uncommented at a time
       private static Class<CompoundObject<String,String>> exploringHowToGetTheArg()
          Class<CompoundObject<String,String>> classarg = null;
          /* Exhibit A: */
      ////     classarg = CompoundObject.class;
             results in compiler error "incompatible types"
             found   : java.lang.Class<GenericWeird.CompoundObject>
             required: java.lang.Class<GenericWeird.CompoundObject<java.lang.String,java.lang.String>>
                   classarg = CompoundObject.class;
                                            ^
             I understand this.  But how to get the type information?
          /* It's obnoxious, but it looks like I will have to construct a temporary
              prototype instance of type
                 CompoundObject<String,String>
              in order to get an instance of
                 Class<CompoundObject<String,String>>
              (see my Question #1) */
          CompoundObject<String,String> proto = new CompoundObject<String,String>("foo", "fum");
          /* Exhibit B: */
      ////     classarg = proto.getClass();
             results in compiler error: "incompatible types"
             found   : java.lang.Class<capture of ? extends GenericWeird.CompoundObject>
             required: java.lang.Class<GenericWeird.CompoundObject<java.lang.String,java.lang.String>>
                   classarg = proto.getClass();
                                            ^
          /* Exhibit C: */
      ////     classarg = proto.getClass().asSubclass(proto.getClass());
             results in compiler error: "incompatible types"
             found   : java.lang.Class<capture of ? extends capture of ? extends GenericWeird.CompoundObject>
             required: java.lang.Class<GenericWeird.CompoundObject<java.lang.String,java.lang.String>>
                   classarg = proto.getClass().asSubclass(proto.getClass());
                                                         ^
          /* Exhibit D: (notice the similarity to C!): */
      ////     Class tmp1 = proto.getClass();
      ////     classarg = tmp1.asSubclass(tmp1);
          /* It compiles (see my Question #2) */
          return classarg;
       } // end method exploringHowToGetTheArg()
    } // end class GenericWeird

    Thanks so much, Bruce. (Oh my goodness, how would I have ever come up with that on my own?)
    So in summary
    This doesn't compile:
          classarg = (Class<CompoundObject<String,String>>)CompoundObject.class;but these do compile:
          classarg = (Class<CompoundObject<String,String>>)(Class)CompoundObject.class;or
          Class coclass = (Class)CompoundObject.class;
          classarg = (Class<CompoundObject<String,String>>)coclass;And this doesn't compile:
           classarg = proto.getClass().asSubclass(proto.getClass());but this does:
           Class tmp1 = proto.getClass();
           classarg = tmp1.asSubclass(tmp1);

  • Instancing a class whose classname is a variable

    I'm currently working on building a rudimentary 2D game engine and development kit program for building objects and I've run into an interesting problem. Here's what I want to do
    1. User creates new object which extends one of my other types of objects with user-defined name
    2. User defines constructor parameters and can alter the code of the object
    3. User hits save button, program writes new file with <user-defined name>.java as it's name
    4. Program compiles the objects
    (This is where I am right now)
    5. Program instances new object whose class is the newly created user defined class
    6. Program saves newly instanced object (easy since they'll be serializable eventually)
    7. Separate program opens the instanced object and uses it
    Now then this poses 2 questions. 1, is there a better way to do this sort of thing? By this sort of thing I mean created a new java class, saving it, instancing it, and using it in a separate program. 2, the main question is, is this even possible? Is it possible to instance a class whose name is determined at runtime? Something tells me it's not possible, simply because that would make it really easy to write dynamic code that changes at runtime and since that's often talked about as a difficult thing I doubt there's any other why to do it. I have another possibility, but it would make loading these objects insanely difficult and since I want them to be editable that means I'd much rather use a different method. Also the other method has some other problems that are hard to explain without getting into what the program does.
    I also would like to throw another question in.
    What's the best (easiest to write) way to detect (at runtime) if one of your programs is performing an infinite recursion? I've been working on a very stupid recursion based pathfinding AI for the same program, it was originally loop based but I realized recursion would cut the code down by a lot and make it smarter. However recursion also introduced an infinite loop problem because the AI works by picking two paths when it hits an object, right and left, then examining those recursively. So when I hit an object, go right, and hit another object the AI tests going back the way it came and gets stuck. Any suggestions would be most appreciated, my current method is to pass each recursive call a list of the points already visited and check if the destination for that call is the same as any of those points then simply cancel going that way however that's not working too well.
    Thanks for any help.

    Jverd - I know right now what constructor I'm calling and what arguments it takes...right now. That's subject to change and I would rather not dig through my code to find where I hard-coded it if another option is available.
    Here's what I have right now, it's giving me an error that newInstance() cannot be applied to newInstance(Object[]). If I try to do newInstance(params[0], params[1]) etc based on the length of params it gives me the same error except it changes newInstance(Object[]) to newInstance(Object, Object) etc
    Object[] params = new Object[textFields.size()];
    for (int i=0; i<textFields.size(); i++)
         if (parameters.get(i) == "int")
              params[i] = Integer.parseInt(textFields.get(i).getText());
         else if (parameters.get(i) == "String")
                 params[i] = textFields.get(i).getText();
         else
              params[i] = null;
    obj = obj.newInstance(params);I know I'm making a stupid mistake but I've never worked with that varargs thing before and so I don't know what stupid mistake I'm making. And in case it helps the constructor I'm trying to call at the moment is for my Item class which looks like this
    public RoNItem(boolean isGrenade, boolean isMedpac, boolean isObjective, int weight, int numberOfItems, String pictureLocation, String name, String description, String soundClipLocation)
    it takes 2 booleans (which I just noticed, so I guess my constructors take ints, Strings and booleans), 2 ints, and 4 strings right now. One of those strings was added yesterday, which is why I'd like to write some code that can adapt. The parameters the user is typing in are already loading from the file so the user will always enter the proper number and type of parameters, I just need to worry about how to pass those.

  • WebAS 6.20: startuperror :  ID000546: Error instancing frame class of a cor

    Hello,
          Please read the entire posting before you answer to the problem.
    I am installing the web middlewear for CRM IDES 4.0 SP4. SAP deliver e-selling scenario (based on 6.20 webas) in a sar file and all I have to is unzip it into a directory and start the j2ee server. Dispatcher starts fine and when starting the server I am getting the following error:
    OS: w2k
    SAP J2EE Engine Version 6.20 PatchLevel 67440.20
    login id:j2eeadm.
    java version: 1.3.1_15
    my jave_home is set.
    memory settings seems to be oj with 512.
    I don't see any file authorisations issues.
    Please help me!
    Loading core services:
    ID000546: Error instancing frame class of a core service com.inqmy.services.dbms.server.DBMSServiceFrame.
    [ServiceManager]: ID000546: Error instancing frame class of a core service com.inqmy.services.dbms.server.DBMSServiceFra
    me.
    java.lang.ClassNotFoundException: com.inqmy.services.dbms.server.DBMSServiceFrame
            at com.inqmy.frame.core.load.ReferencedLoader.loadClass(ReferencedLoader.java:168)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
            at com.inqmy.frame.core.load.ReferencedLoader.loadClass(ReferencedLoader.java:105)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:190)
            at com.inqmy.core.service.container.ServiceWrapper.start(ServiceWrapper.java:122)
            at com.inqmy.core.service.container.MemoryContainer.startSingleService(MemoryContainer.java:645)
            at com.inqmy.core.service.container.MemoryContainer.startCoreServices(MemoryContainer.java:160)
            at com.inqmy.core.service.container.AbstractServiceContainer.init(AbstractServiceContainer.java:130)
            at com.inqmy.core.Framework.loadSingleManager(Framework.java:322)
            at com.inqmy.core.Framework.loadManagers(Framework.java:117)
            at com.inqmy.core.Framework.start(Framework.java:78)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.inqmy.boot.FrameThread.run(FrameThread.java:46)
            at java.lang.Thread.run(Thread.java:479)
      Starting core service monitor ... done.
      Starting core service file ... done.

    Hi Srini,
    The dbms.jar file in <server>/services/dbms directory is missing or corrupted. Get a new version of the sar file or check for insufficient disk space (in case extraction has failed).
    Best Regards: Iavor

  • Create instance of class

    Hi all,
    I have problem with creating static fields in class. I have separate packages in my project and I need to have instances for all classes in this packages. I create instance of class using next code:
    public class Digest
       private static Digest digest = null;
       protected Digest ()
      public static Digest getInstance()
             if(digest == null)
              digest = new Digest();
            return digest;
      public static void clearInstacePool()
             digest = null;
    }But I have problem with deleting my packages and applet after I call Digest.getInstance(). I need to implement clearInstacePool() method to set reference of digest to null in unistall() method of my applet. Question is: how to create instance of class without implementing clearInstacePool()?

    Question is: how to create instance of class without implementing clearInstacePool()?That question doesn't make sense,or at least it is ambiguous. 'Create instance' usually involves the 'new' operator, which has nothing to do with what methods are implemented. Do you mean how to code the class without implementing clearInstancePool()?

  • Blocking DataFactory.INSTANCE.create(Class)

    Hello,
    we are using SOA suite 11g 1.1.2 and have some issues with SDO objects. Our EJB web service returns a SDO object and calls commonj.sdo.helper.DataFactory.INSTANCE.create(Class) to construct it. This call however blocks and jrockit mission control revealed
    that all cpu is consumed within org.eclipse.persistence.sdo.helper.delegates.SDODataFactoryDelegate. In a debugging session we found
    that the following loop never exits:
    (in org.eclipse.persistence.sdo.helper.delegates.SDODataFactoryDelegate)
    public DataObject create(Class interfaceClass) {
    ClassLoader contextLoader = xmlHelper.getLoader();
    ClassLoader interfaceLoader = interfaceClass.getClassLoader();
    ClassLoader parentLoader = contextLoader;
    boolean loadersAreRelated = false;
    *while ((parentLoader != null) && (!(loadersAreRelated))) {*
    if (parentLoader == interfaceLoader)
    loadersAreRelated = true;
    parentLoader = contextLoader.getParent();
    It seems there's a mixup with the classloaders here and the exit condition is never satisfied.
    The flow of events is as such: BPEL process ---(ejb binding)---> stateless session bean ----> DataFactory.INSTANCE.create(Class)
    Inside the SCA-INF/lib folder of the BPEL we include a jar that contains the .class files of the EJB's remote interface.
    The problem can be resolved by calling SDOHelper.INSTANCE.defineSchema() right before every DataFactory.INSTANCE.create(Class) invocation but this is a very expensive call...
    Can anyone suggest why this happens and/or some solution?
    Thanks

    Were you able to fix this ? I am getting same exception
    Edited by: Sam on Apr 12, 2012 10:33 AM

  • Dynamically finding correct instance of class

    I am running two different applications under same context in tomcat. Both application has their own set of classes and common classes which are accessed by both applications. One of the common class say Class A is implemeting common interface say B is extended by both applications having their own subclasses C and D respectively. Now when some other common class Say X invokes method on interface B , at runtime class X should be able to invoke method on correct instance C or D depending on which application request came from. Is there any way where Class X can dynamically find the correct instance of class C or D to invloke method on?

    My answer is in your other thread.

  • ClassCastException during Deserialization : Assigning instance of class...

    Hi All,
    I'm writing a client-server application.
    The server sends serializable objects to the client via a socket.
    When the client try to deSerialize the Object( in.readObject() ),
    I got Exception:
    java.lang.ClassCastException: Assigning instance of class java.io.ObjectStreamClass to field seda.sandStorm.lib.http.httpResponse#contentType
    at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2266)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:514)
    at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1407)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:381)
    at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2258)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:514)
    at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1407)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:381)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
    at seda.Dseda.internal.ObjectReader.readObj(ObjectReader.java:96)
    at seda.Dseda.internal.ObjectReader.readPacket(ObjectReader.java:77)
    Both client and server have exactly the same copy of the classes.
    Any help would be apprciated.
    Thanks, Gil.

    Hi,
    I hava managed to solved the problem:
    The ObjectOutputStream need to be reset after every write(..).
    Gil.

  • An error occurred while getting property "userId" from an instance of class

    Running application SRDemo (Tutorial Chapter 6 Implementing Login Security)
    After logging, the List page popped up. But no data returned. Get Error
    JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: java.lang.RuntimeException, msg=javax.servlet.jsp.el.ELException: An error occurred while getting property "userId" from an instance of class oracle.srdemo.view.UserInfo.
    Questions:
    1. What are possible reasons to cause the getting property "userId" problem?[
    2. Why the Login page asked User Name and Password and the program used the query with "WHERE (EMAIL = 'sking')"
    The Log file shows the select statement:
    SELECT USER_ID, FIRST_NAME, LAST_NAME, CITY, POSTAL_CODE, EMAIL, STATE_PROVINCE, COUNTRY_ID, STREET_ADDRESS, USER_ROLE FROM USERS WHERE (EMAIL = 'sking')
    [TopLink Info]: 2006.11.08 11:07:09.468--ServerSession(1235)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--SRDemoSession login successful
    [TopLink Finer]: 2006.11.08 11:07:09.468--ServerSession(1235)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--client acquired
    [TopLink Fine]: 2006.11.08 11:07:09.500--ServerSession(1235)--Connection(1925)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--SELECT USER_ID, FIRST_NAME, LAST_NAME, CITY, POSTAL_CODE, EMAIL, STATE_PROVINCE, COUNTRY_ID, STREET_ADDRESS, USER_ROLE FROM USERS WHERE (EMAIL = 'sking')
    [TopLink Finer]: 2006.11.08 11:07:09.578--ClientSession(2021)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--client released
    [TopLink Finer]: 2006.11.08 11:07:09.625--ServerSession(1235)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--client acquired
    [TopLink Fine]: 2006.11.08 11:07:09.625--ServerSession(1235)--Connection(1922)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--SELECT USER_ID, FIRST_NAME, LAST_NAME, CITY, POSTAL_CODE, EMAIL, STATE_PROVINCE, COUNTRY_ID, STREET_ADDRESS, USER_ROLE FROM USERS WHERE (EMAIL = 'sking')
    [TopLink Finer]: 2006.11.08 11:07:09.625--ClientSession(2027)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--client released
    2006-11-08 11:07:09.640 WARNING JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: java.lang.RuntimeException, msg=javax.servlet.jsp.el.ELException: An error occurred while getting property "userId" from an instance of class oracle.srdemo.view.UserInfo
    2006-11-08 11:07:09.640 WARNING JBO-29000: Unexpected exception caught: java.lang.RuntimeException, msg=javax.servlet.jsp.el.ELException: An error occurred while getting property "userId" from an instance of class oracle.srdemo.view.UserInfo
    2006-11-08 11:07:09.640 WARNING javax.servlet.jsp.el.ELException: An error occurred while getting property "userId" from an instance of class oracle.srdemo.view.UserInfo
    2006-11-08 11:07:11.515 WARNING rowIterator is null
    2006-11-08 11:07:11.515 WARNING rowIterator is null
    Process exited.

    Hi,
    I got the answer to my question. The tables were not populated. So I ran the script - populateSchemaTables.sql, and got the data into the tables. The error is gone!
    Lin

  • Error creating instance of class from same package

    When I try to create an instance of a class that is in the same package, my IDE indicates that the constructor can not be found. Can anyone tell me what is wrong? Thanks. Below are the codes for both classes:
    package com.practice;
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    public class WebProject extends Applet{
         public void init(){
                    // The following line is where the IDE indicates there is an error
              UserInterface gui = new UserInterface();
         } // end init()
         public void start(){
         } // end start()
         public void stop(){
         } // end stop()
         public void destroy(){
         } // end destory()
    } // end class
    package com.practice;
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    public class UserInterface extends Applet{
         JPanel menuPanel = new JPanel();
         JPanel contentPanel = new JPanel();
         JPanel savePanel = new JPanel();
         ImageIcon saveIcon = new ImageIcon("workspace/images/toolbarButtongraphics/general/Save24");
         JButton saveButton = new JButton("Save", saveIcon);
         public UserInterface(){
              savePanel.add(saveButton);
              setLayout(new BorderLayout());
              add(menuPanel, BorderLayout.NORTH);
              add(contentPanel, BorderLayout.CENTER);
              add(savePanel, BorderLayout.SOUTH);
    } // end UserInterface class

    Thanks for the explanation and example. At first, I didn't understand what you were getting at, but after reading "Using Top-Level Containers" and "How to Use Root Panes" java tutorials it made much more sense. Unfortunately, the books I've read up to this point, did not cover those topics at all. The books simply stated that the first step in creating a Swing gui was to extend the JFrame, or JApplet, or etc.
    Unfortunately, my original problem persists. I continue to get compile-time errors such as:
    TestUserInterface.java:5: cannot find symbol
    symbol: class UserInterface
    location: class projects.web.TestUserInterface
                          UserInterface ui = new UserInterface(); Anyone know why?
    Both the classes are in the same named packaged. Below is my code:
    package projects.web;
    import java.awt.*;
    import javax.swing.*;
    public class UserInterface extends JFrame{
         JPanel menuPanel = new JPanel();
         JPanel contentPanel = new JPanel();
         JPanel selectionPanel = new JPanel();
         JButton save = new JButton("Save");
         JButton addFiles = new JButton("Add");
         public UserInterface(){
         super("File Upload");
         setSize(500, 500);
         menuPanel.add(addFiles);
         selectionPanel.add(save);
         setLayout(new BorderLayout());
         add(menuPanel, BorderLayout.NORTH);
         add(contentPanel, BorderLayout.CENTER);
         add(selectionPanel, BorderLayout.SOUTH);
         } // end constructor
    } // end UserInterface class
    package projects.web;
    public class TestUserInterface{
         public static void main(String[] args){
              UserInterface ui = new UserInterface();
    } // end TestUserInterface class

  • Private creation of instance WITHIN class dumps

    Hi,
    So, I've activated some of my classes and executed it. The class is to be instantiated privately. Thus, also the constructor is private.
    Now, I've got a static attribute ro_object. And I've got a static public method CREATE, which shall create this static attribute via CREATE ro_object.
    Unfortunately, the program dumps at the call of the static method right at the point, where I call CREATE OBJECT.
    class is ZPLM_DL_CL_DM_SPECIFICATION.
    Error in the ABAP Application Program
    The current ABAP program "ZPLM_DL_CL_DM_SPECIFICATION===CP" had to be
    terminated because it has
    come across a statement that unfortunately cannot be executed.
    The following syntax error occurred in program
    "ZPLM_DL_CL_DM_DL_TYPE_CONTROL=CP " in include
    "ZPLM_DL_CL_DM_DL_TYPE_CONTROL=CM002 " in
    line 17:
    "You cannot create an instance of the class "ZPLM_DL_CL_DM_DL_TYPE" out"
    "side the class . . . . . . ."
    The include has been created and last changed by:
    Created by: "D052039 "
    Last changed by: "D052039 "
    Error in the ABAP Application Program
    The current ABAP program "ZPLM_DL_CL_DM_SPECIFICATION===CP" had to be
    terminated because it has
    come across a statement that unfortunately cannot be executed.
    At the code block at the bottom of the page, I've got the constructor of this class and the first line is selected (the one with METHOD constructor.)
    So, if you want more code, I'll provide it.
    To me, this doesn't make sense, as other similar classes look the very same but won't dump. Also, if I make the ctor public and the instantiation public, the dump stays! I've tried to re-activate each method but it doesn't help.
    Any ideas?
    Kind regards,
    Michael
    Edited by: Michael Alexander Voelkel on Oct 15, 2009 11:45 AM
    Edited by: Michael Alexander Voelkel on Oct 15, 2009 11:45 AM

    I saw this, too. The point is: I don't try to create an instance of this other class, it's just not true and the object which I try to create is of the type of the specification-class for sure.. The code seems to be old. Re-activiating doesn't help it and the application throws dumps linked to code statements which don't exist anymore.
    Edit: It works now. After my lunch. After I haven't changed anything... does anyone have an explanation for that?
    Anyway, the actual problem is now solved. Thank you all for your time and effort!
    Edited by: Michael Alexander Voelkel on Oct 15, 2009 1:15 PM

  • Trying to access methods from a .class file by creating instance of class

    Hey all,
    I'm hoping you can help. I've been given a file "Input.class" with methods such as readInt(), readString(), etc. I have tried creating instances of this class to make use of it, but I receive the error "cannot find symbol : class Input".
    If you could help at all, I would greatly appreciate it.
    Here's my code. The first is the base program, the second is the driver.
    import java.util.*;
    public class CarObject
         private String makeType = "";
         private String modelType = "";
         private int yearOfRelease = 0;
         private double numOfMiles = 0.0;
         public void setFilmTitle(String make)
              makeType = make;
         public void setMediaType(String model)
              modelType = model;
         public void setYearOfRelease(int year)
              yearOfRelease = year;
         public void setNumOfMiles(double miles)
              numOfMiles = miles;
         public String getMakeType()
              return makeType;
         public String getModelType()
              return modelType;
         public int getYearOfRelease()
              return yearOfRelease;
         public double getNumOfMiles()
              return numOfMiles;
    The program is used by a rental car company and the object takes on desired attributes.
    import java.util.*;
    public class TestCarObject
         static Scanner keyboard = new Scanner(System.in);
         public static void main(String[] args)
              System.out.println("Please answer the following questions regarding your rental car order.");
              Input carinput = new Input();
              String makeType = carinput.readString("Enter your desired make of car: ");          
              String modelType = carinput.readString("Enter your desired model of car: ");
              int yearOfRelease = carinput.readInt("Enter the oldest acceptable year of release to rent: ");
              double numOfMiles = carinput.readDouble("Enter the highest acceptable number of miles: ");
              System.out.println("Make: " + makeType);
              System.out.println("Model: " + makeType);
              System.out.println("Year: " + makeType);
              System.out.println("Mileage: " + makeType);
    }

    No, I don't know the package name....Is there a way
    to import the Input.class by itself without importing
    the entire packge?
    I tried extending the driver program too...It didn't
    work either...
    Message was edited by:
    BoxMan56How do you know you have a class called Input.class ?
    You got a jar file which contains it ? or just a simple .class file ?
    You have to set the classpath in either case.
    But for the former, you should also need to explicitly telling which package containing the class file you looking for (i.e. Input.class)
    e.g. java.util.Vector which is a class called Vector inside java.util package.
    You don't have to import the whole package, but you should tell which package this class belongs to.

  • Can't create new instance of class in servlet.

    I'm running Tomcat 5.5 and am trying to create a new instance of a class in a servlet. The class is an Apache Axis (1.4) proxy for a Web Service.
    Is there any particular reason this is happening, and any way to fix it?
    The stack trace is as follows:
    WARNING: Method execution failed:
    java.lang.ExceptionInInitializerError
         at org.apache.axis.utils.Messages.<clinit>(Messages.java:36)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:184)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.access$200(EngineConfigurationFactoryFinder.java:46)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(EngineConfigurationFactoryFinder.java:128)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:113)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:160)
         at org.apache.axis.client.Service.getEngineConfiguration(Service.java:813)
         at org.apache.axis.client.Service.getAxisClient(Service.java:104)
         at org.apache.axis.client.Service.<init>(Service.java:113)
         at server.proxies.webservicex.net.stockquote.StockQuoteLocator.<init>(StockQuoteLocator.java:12)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)

    Of course there's a particular reason it's happening. Nothing in a computer happens unless it's for a particular reason. You question ought to be what is that reason.
    Well, I don't know what it is. The class org.apache.axis.utils.Messages threw some kind of exception when it was being loaded, because <clinit> means "class initialization" in a stack trace. That would most likely be in a static initializer block in that class. I expect it is because of some mis-configuration in your system, but you'd have to read and understand the apache code to find out what. Or maybe ask over at the Axis site, where there might be a forum or a mailing list.

  • Address instance of class with webserviceconnector

    Hi,
    what am I missing here?
    I'd like to create a movieclip which has linkage to a class.
    The class should have a function that calls a webservice that
    returns some data.
    The movieclip itself has an instance - i_checkHolder - which
    just is a graphic box,
    Now to my, I guess novice, problem:
    How do I address the "i_checkholder" of the current instance
    of this class ?
    I can not obviously use _this_ since that is the
    webserviceconnector itself.
    Cut code:
    import flash.events.*;
    import mx.data.components.WebServiceConnector;
    class AwcGroup extends MovieClip {
    function initChecks():Void {
    var wsConn:WebServiceConnector = new WebServiceConnector();
    wsConn.addEventListener("result", renderChecks(groupId));
    wsConn.WSDLURL = "
    http://sestivex01d/monitorws/amon.asmx?wsdl";
    wsConn.operation = "GetMonitorGroupChecks";
    wsConn.params = [groupId, false];
    wsConn.suppressInvalidCalls = true;
    wsConn.trigger();
    function renderChecks(evt:Object) {
    this["i_checkholder"]._alpha = 40; // I know this is wrong
    I would be grateful for any reply,
    Thanks

    Thanks so much, Bruce. (Oh my goodness, how would I have ever come up with that on my own?)
    So in summary
    This doesn't compile:
          classarg = (Class<CompoundObject<String,String>>)CompoundObject.class;but these do compile:
          classarg = (Class<CompoundObject<String,String>>)(Class)CompoundObject.class;or
          Class coclass = (Class)CompoundObject.class;
          classarg = (Class<CompoundObject<String,String>>)coclass;And this doesn't compile:
           classarg = proto.getClass().asSubclass(proto.getClass());but this does:
           Class tmp1 = proto.getClass();
           classarg = tmp1.asSubclass(tmp1);

  • New Instance of class

    I have two classes. In one class I have created a new instance of the other class as follows:
    class1{
    class2 c2 = new class2(this);
    However in class2 I now want to create a new instance of class1 but I cant do this as I go into an infinite loop right. What can I do???

    In class1 I have a JTable, with a number of colums and
    each row containing data pertaining to a record. In
    class2 I have a text area, comboboxes, and other such
    gui items. class1 extends JFrame. class2 extends
    JPanel. When the user selects a row the gui created in
    class2 is added to the frame in class1 (south of
    JTable)
    Each time the user selects a different row, the
    appropriate data (data from the row selected)is
    displayed in the gui items in class2 - hence the need
    for a new instance of class2 in class1.
    However when the user presses the save button in the
    class 2 gui I wish the data to be updated in the
    class1 JTable - hence the need for a new instance of
    class1 in class2. I can see the need for class2 to have a reference to the instance of class1. But it does not sound like you need or want to create a new instance of class1. class1 is a JFrame. If you pass a reference to class1 in the constructor of class2, then class2 can use the reference to the class1 instance to add, remove or otherwise update class1.

  • Instance of classes

    Which of these methods am i able to call up without having to create an instance of the class? I think it is the constructor of the class... am i right??
    public first ( )
    public void second ( )
    public static void third (  )
    public int fourth ( )
    public void fifth ( )

    u guys are retardedAnd you're a rude, lazy idiot who I've probably
    helped before but will never help again.@jverd: you have helped him. Surely youremember
    I remember seeing his name on other threads in the
    past, but I don't recall if I've answered any. Odds
    are good I have though.
    How do i create an "if" statement that will set
    ll set
    a maximum and minimum window size???Was that a question of his that I answered? Or are
    you asking that question here yourself?That was his question, and I seem to remember you got a
    polite reply because the code you provided in response worked.

Maybe you are looking for