Initialize object array without specifying dimention

Hi,
Can anybody help me in suggesting a solution for this:
I have a class called Test. I can create instance array and initialize for class Test using
Test test[] = {new Test(), new Test()};
or
Test test[] = new Test[100];
statement.
How can I give infinite initialization for Test
Thank you
Regards
Anoop

Anoop.Retna wrote:
Hi,
Can anybody help me in suggesting a solution for this:
I have a class called Test. I can create instance array and initialize for class Test using
Test test[] = {new Test(), new Test()};
or
Test test[] = new Test[100];
statement.
How can I give infinite initialization for TestYou can't. There's no such thing.
If you want a container that can expand to accomodate a variable number of items you can use a List.
%

Similar Messages

  • Convert text string file to object array without outputting to file first?

    I have a log file that is just a text string file which is appended to with Out-File.  If the log file does not exist I pipe headers to it so that I can import the data as CSV.  For example:
    DATA.LOG
    DATE,TIME,RESPONSE_TIME
    05-28-2014, 14:47, 132
    05-28-2014, 14:50, 94
    05-28-2014, 14:53, 72
    I'm using Microsoft Chart Controls to graph the data; it takes it in via CSV format.  If I'm going to chart all the entries in DATA.LOG I can simply IMPORT-CSV DATA.LOG.  But I only want to graph the 20 most recent entries.
    Perhaps there is a better way to do this, but to maintain the header and get the 20 most recent entries I'm using select.
    $DATA+=Get-Content .\data.log | select -first 1
    $DATA+=Get-Content .\data.log | select -last 20
    The problem is $DATA is of type system string so I can't use it directly with Chart Controls; I need to get it in CSV format first.  I can Out-File $DATA and then use IMPORT-CSV.  But I'd prefer to not have to use
    the temporary file.  Any suggestions on how I can accomplish this objective? 

    Import-CSV creates an object with the 'header' becoming the named values in the array.  The code I posted does the same thing as your 4 lines of code in one line of code:
    Much more quickly:
    PS C:\temp> (1..1000 | measure-command {import-csv .\data.log | select -last 2}).totalseconds
    0.4792951
    PS C:\temp> (1..1000 | measure-command {$DATATMP=@();$DATATMP+=Get-Content .\data.log | select -first 1;$DATATMP+=Get-Content .\data.log | select -last 2;ConvertFrom-CSV $DATATMP}).totalseconds
    1.6227726
    You're more than welcome to use whatever code you want, but if you want to improve your Powershell knowledge you should try to understand the object model around which Powershell is built, it is powerful and efficient.
    I hope this post has helped!

  • How to initialize Object  Array Data Provider (OADP)with data from txt file

    Hi,
    I want to show in a table some columnar data from a txt file. I ran the creator demo application on OADP successfully. http://blogs.sun.com/divas/entry/using_the_object_array_data
    I created a javabean class to read a txt file.However, I am stuck at how I can fill the data into an OADP array:
    I am familiar with C extensively but not much at java. can anyone help??
    thanks..
    dr.am.mohan rao

    Thanks for that. I changed it a little bit, but when i ran this script, got ORA-06532: Subscript outside of limit.
    declare
    O_voucher_comment SYSADM.AP_COMMENT_COLL := sysadm.ap_comment_coll(null);
    begin
    FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 0, 'KEHE', O_voucher_comment);
    end;
    PROCEDURE get_voucher_comments (
    v_bu_in IN VARCHAR2,
    v_voucher_in IN VARCHAR2,
    v_line_in IN NUMBER,
    v_userid IN VARCHAR2,
    voucher_comment OUT      sysadm.ap_comment_coll
    IS
    i NUMBER := 1;
    v_comments VARCHAR2 (254) := ' ';
    comment_type sysadm.ap_comment_type;
    v_line_num NUMBER := 0;
    CURSOR get_all_comment
    IS
    SELECT voucher_line_num, descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in;
    CURSOR get_line_comment
    IS
    SELECT descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in
    AND voucher_line_num = v_line_in;
    BEGIN
    --voucher_comment() := SYSADM.ap_comment_type (NULL, NULL, NULL, NULL, NULL, NULL);
    --' ', ' ', 0, ' ', '', ' ' sysadm.ap_comment_coll
    voucher_comment := sysadm.ap_comment_coll(null);
    IF v_line_in = 0
    THEN
    OPEN get_all_comment;
    LOOP
    FETCH get_all_comment
    INTO v_line_num, v_comments;
              if i > 1
              then
                   voucher_comment.EXTEND;
              end if;
    voucher_comment (i) := ap_comment_type (v_bu_in,
    v_voucher_in, v_line_num, v_userid,
    TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), v_comments );
    i := i + 1;
    END LOOP;
    ELSE
    OPEN get_line_comment;
    LOOP
    FETCH get_line_comment
    INTO v_comments;
              voucher_comment.extend(6);
    voucher_comment (i) := ap_comment_type (v_bu_in, v_voucher_in, v_line_num, v_userid, TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS' ), 'DD-MON-YYYY HH24:MI:SS'), v_comments);
    i := i + 1;
    END LOOP;
    END IF;
    END get_voucher_comments;

  • Abstract  object array  initialization

    Hi everybody!
    I have a question, I know you can help me.
    I created an abstract class called publication, and two other clases called Tape and Book that derive from the publication class. Now, in the application I have :
    Publication BookTape[];
    when I compile my program I have one error which is that I haven't initialize the BookTape[] object array. My question is How I can initialize an object that comes from an abstract class? could you help me?
    Thank you !!!

    Publication bookTapes[] = new Publication[10];That will create your array (note, this has nothing to do with instantiating abstract classes).
    If you actually want to have something in your array, you need to fill it with subclasses of Publication since it's an abstract class.
    So.
    for(int i = 0;i < bookTapes.length;i++)
       bookTapes[i] = new SubclassOfPublication();

  • Object Array problem in Websphere WebServices

    Hi,
    Can someone help me out with a situation that I am stuck with in WebServices.
    I have a WebService which returns a DTO which has a getter and setter for an array of another type of DTO object.
    Sample:-
    public class MyDTO extends AnotherDTO implements Serializable {
    private InnerDTO qcDtoList[] = new InnerDTO[0];
    public MyDTO() {
    public InnerDTO[] getQcDtoList() {
    return qcDtoList;
    public void setQcDtoList(InnerDTO[] resEDXDTOs) {
    qcDtoList = resEDXDTOs;
    But when I generate the WSDL for the webservice using WSAD 5.1 that uses the above DTO, the server side generated skeleton file looks like:-
    public class MyDTO extends AnotherDTO implements java.io.Serializable {
    private InnerDTO[] qcDtoList;
    public MyDTO() {
    public InnerDTO[] getQcDtoList() {
    return qcDtoList;
    public void setQcDtoList(InnerDTO[] qcDtoList) {
    this.qcDtoList = qcDtoList;
    As you can see from above, my initialization info is not available in the generated skeleton. I also tried putting the initialization in the constructor, with no effect.
    What could be the reason for this? And is it possible to initialize my InnerDTO without losing it in the generated skeleton?
    I simply want to initialize the object array.
    If I need to modify my WSDL, what additional annotations should I add on the WSDL to get the desired effect?
    I use WSAD's (Websphere Studio App Developer) IBM Websphere Webservices protocol and the JDK version is 1.3.1 and WSAD version is 5.1.
    I would really appreciate if you can throw light on this?
    Thanx and Regds,
    Prashanth.

    Thank you for the quick response. I looked at the example you suggested and made the following changes. Now I'm receiving an "Invalid datatype" error on the "SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer))" statement. I must be missing something simple and I just can't put my finger on it.
    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    rs OUT RSType)
    AS
    /* PURPOSE: Return Search Results for the Category and Keyword Provided
    VARIABLES:
    v_categories = Document Categories array entered
    v_term = Keyword entered
    rs = Result Set
    TYPE tbl_integer IS TABLE OF INTEGER;
    tbl_cat tbl_integer;
    BEGIN
    FOR i IN 1 .. v_categories.COUNT
    LOOP
    tbl_cat.EXTEND(1);
    tbl_cat(i) := v_categories(i);
    END LOOP;
    OPEN rs FOR
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    FROM TBL_ARCHIVE_DOCUMENTS A,
    TBL_ARCHIVE_DOC_CAT B,
    TBL_ARCHIVE_DOC_KEYWORDS C
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY IN (SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer)))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;

  • How do I initialize an array after getting xml data via httpservice?

    I am having a problem trying to initialize an array with data from an external xml file obtained via httpservice.  Any help/direction would be much appreciated.  I am using Flex 4 (Flash Builder 4).
    Here is my xml file (partial):
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Root>
        <Row>
            <icdcodedanddesc>00 PROCEDURES AND INTERVENT</icdcodedanddesc>
        </Row>
        <Row>
            <icdcodedanddesc>00.0 THERAPEUTIC ULTRASOUND</icdcodedanddesc>
        </Row>
        <Row>
            <icdcodedanddesc>00.01 THERAPEUTIC US VESSELS H</icdcodedanddesc>
        </Row>
        <Row>
            <icdcodedanddesc>00.02 THERAPEUTIC ULTRASOUND O</icdcodedanddesc>
        </Row>
    </Root>
    Here is my http service call:
    <s:HTTPService id="icdcodeservice" url="ICD9V2MergeNumAndDescNotAllCodes.xml"
                           result="icdcodesService_resultHandler(event)" showBusyCursor="true"  />
    (I have tried resultFormat using object, array, xml).
    I am using this following Tour de Flex example as the base -http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500
    and updating it with the httpservice call and result handler.  But I cannot get the data to appear - I get [object Object] instead.  In my result handler code  I use "icdcodesar = new Array(event.result.Root.Row);"  and then "icdcodesar.refresh();".
    The key question is: How to I get data from an external xml file into an array without getting [object Object] when referencing the array entries.  Thanks much!
    (Tour de Flex example at http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500  follows)
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:local="*"
                   skinClass="TDFGradientBackgroundSkin"
                   viewSourceURL="srcview/index.html">
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/mx";
            @namespace local "*";
            s|Label {
                color: #000000;
        </fx:Style>
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                private var names:ArrayCollection = new ArrayCollection(
                    ["John Smith", "Jane Doe", "Paul Dupont", "Liz Jones", "Marie Taylor"]);
                private function searchName(item:Object):Boolean
                    return item.toLowerCase().search(searchBox.text) != -1;
                private function textChangeHandler():void
                    names.filterFunction = searchName;
                    names.refresh();
                    searchBox.dataProvider = names;
                private function itemSelectedHandler(event:SearchBoxEvent):void
                    fullName.text = event.item as String;   
            ]]>
        </fx:Script>
        <s:layout>
            <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" />
        </s:layout>
        <s:Panel title="Components Samples"
                 width="600" height="100%"
                 color="0x000000"
                 borderAlpha="0.15">
            <s:layout>
                <s:HorizontalLayout horizontalAlign="center"
                                    paddingLeft="10" paddingRight="10"
                                    paddingTop="10" paddingBottom="10"/>
            </s:layout>
            <s:HGroup >
                <s:Label text="Type a few characters to search:" />
                <local:SearchBox id="searchBox" textChange="textChangeHandler()" itemSelected="itemSelectedHandler(event)"/>
            </s:HGroup>
            <mx:FormItem label="You selected:" >
                <s:TextInput id="fullName"/>
            </mx:FormItem>
        </s:Panel>
    </s:Application>

    Hello,
    Instead of extracting the first zero element from the vid array, you should take that out and connect it allone.
    Attachments:
    init.bmp ‏339 KB

  • Access other schema's table without specify the schema name

    Hi, need ur help again,
    I would like to access other schema's table without specify the schema name. for example,
    select * from hr.jobs;
    What priviledges i need if i want to select the data in this way:
    select * from jobs;
    Thanks!

    Public synonyms have their place, but are not generally a good idea as they will cause conflicts with other schemas and applications. Another think that you can do is issue the
    ALTER SESSION set CURRENT_SCHEMA = schema;
    The CURRENT_SCHEMA (8i and above) parameter changes the current schema of the session to the specified schema. Subsequent nqualified references to schema objects during the session will resolve to objects in the specified schema. The setting persists for the duration of the session or until you issue another ALTER SESSION SET CURRENT_SCHEMA statement. CURRENT_SCHEMA is a session parameter only, not an initialization parameter.
    This setting offers a convenient way to perform operations on objects in a schema other than that of the current user without having to qualify the objects with the schema name. This setting changes the current schema, but it does not change the session user or the current user, nor does it give you any additional system or object privileges for the session.

  • How do you create an array without using a shell on the FP?

    I want to be able to read the status of front panel controls (value, control box selection, etc.) and save it to a file, as a "configuration" file -- then be able to load it and have all the controls set to the same states as were saved in the file. I was thinking an array would be a way to do this, as I have done that in VB. (Saving it as a text file, then reading lines back into the array when the file is read and point the control(s) values/states to the corresponding array element.
    So how do I create an array of X dimensions without using a shell on the front panel? Or can someone suggest a better way to accomplish what I am after? (Datalogging doesn't allow for saving the status by a filename, so I
    do not want to go that route.)

    Thanks so much m3nth! This definitely looks like what I was wanting... just not really knowing how to get there.
    I'm not sure I follow all the icons. Is that an array (top left with 0 constant) in the top example? And if so, that gets back to part of my original question of how to create an array without using a shell on the FP. Do I follow your diagram correctly?
    If I seem a tad green... well I am.
    I hope you understand the LabVIEW environment and icons are still very new to me.
    Also, I had a response from an NI app. engineer about this problem. He sent me a couple of VI's that he threw together approaching this by using Keys. (I still think you are pointing to the best solution.) I assume he wouldn't mind m
    e posting his reply and the VI's for the sake of a good, thorough, Roundtable discussion. So here are his comments with VI's attached:
    "I was implementing this exact functionality this morning for an application I'm working on. I only have five controls I want to save, but they are all of different data types. I simply wrote a key for each control, and read back that key on initialization. I simply passed in property node values to the save VI at the end, and passed the values out to property nodes at
    the beginning. I've attached my initialize and save VI's for you to view. If you have so many controls that this would not be feasible, you may want to look into clustering the controls and saving the cluster as a datalog file.
    Attachments:
    Initialize_Settings.vi ‏55 KB
    Save_Settings.vi ‏52 KB

  • How to get the name of a field without specifying it as a string (somehow v

    Is it possible to get the name of a field (or method) somehow via the class in which it is declared?
    The reason why I ask is, that quite often the name of a field is important, because the name is the anchor for further processing, like for example when using reflection (e.g. Class.getfield(“NameOfTheField”)).
    Assume you have class FooSimple with the field “String firstName”.
    Now you would do something like this:
    Class<FooSimple> cls = FooSimple.class;
    Field f = cls.getField("firstName");
    The problem is, that the string “firstName” is kind of “hard coded”. When the name of the field in class FooSimple changes (e.g. to “theFirstName”), the invocation will not work anymore when you forget to change the string too.
    I think it would be very helpful to have access to the name of the field directly via the class by doing something like this.
    Class<FooSimple> cls = FooSimple.class;
    Field f = cls.getField(FooSimple.firstName.fieldName);
    The Java Compiler would then resolve “FooSimple.firstName.fieldName” to the string “firstName”. When later the name of the field is changed, the IDE would change the name everywhere where it is used. So if the name of the field would be changed to “theFirstName” the IDE would also change the statement to
    Class<FooSimple> cls = FooSimple.class;
    Field f = cls.getField(FooSimple.theFirstName.fieldName);
    A technique like this would be in my opinion much more safety and more generic.
    Any ideas?
    Best Regards.

    Well, I think the discussion is going in a wrong direction because the original issue was not to discuss if it is worth coding some helper classes or a framework or that like. Let me bring it back to my original point.
    Basically you can reduce my original question to this:
    Currently it is possible to use the reflection API on a class level without specifying the name of the class with a string constant.
    My issue is, that I think it would be a nice extension for Java, if the same would be possible for field variables of a Java class. Currently the only way you can do this is by specifying the field variable with a string constant.
    Let me bring some motivations which brought me to this issue.
    Assume you have an entity bean which represents a DB table and you use Java Persistence (either JPA or something like Hibernate). Then you would have a class looking like this (very simple sample to make this reply shorter).
    @Entity
    @Table(name = "PERSON")
    public class Person implements Serializable {
         @Column(name = "NAME")
         private String name;
    // … constructor, getter, setter, etc. not listed here
    }The whole issue of the design of JPA is, that such entity beans represent the mapping between the object model and the DB model, the mapping is expressed with annotations.
    Okay, now let’s assume you write a query in Query Language, e.g.
    String sql = “select p from Person p where name = :name”;“name” is the name of the field variable, “:name” is the parameter you later set with “Query.setParameter” method.
    What is not so nice is the fact, that you use the name of the class and the name of the field variables “hardcoded” to construct the query. Now you could think that basically this information is part of your entity class. First you start with the name of the class (i.e. the table name) to decouple this “hardcoding”.
    You could write instead:
    String sql = “select p from “ + Person.class.getSimpleName() + “ p where name = :name”;This is really nice, because whenever you change the name of your Person class, this change happens automatically for the sql statement as well.
    I think the next thoughts are obvious, now, since you have decoupled the “hardcoded” part of the name of the class, you would like to do the same for the names of the field variables. But now you are stuck, there is no way to do this using a similar technique like for the name of the class. Either you stay with the query as it is now, or, to make it a little bit better, you code string constants for the field variables and use them. This issue brought me to the point that I think it would be nice to have the possibility to get the name of a field variable in a similar way as you can get it for the name of the class.
    Conceptually it is just to go one level deeper, i.e.
    first level is to get the name of a class
    second level is to get the name of the field variable of a class.
    Another sample would be, if you want to code something by using reflection. You have perfectly access to the reflection API starting at the class level like Person.class.allTheNiceReflectionMethods. There is no need to specify the class first with a string constant first, you directly start with the class, you can even be generic and just work on the Class.class level and still have access to all these nice methods to get out the information you need.
    But if you need to start with a very specific field variable (like in the sample above), you must go by using a string constant like Person.class.getDeclaredField(“name”).
    So basically I think that there exist already millions of lines of Java code where a field variable is specified for further processing, especially in combination with the reflection functionality and everywhere the field variables are specified by these string constants in double quotes. I would assume, that everyone has the same problem, once changing the name of the field variable means to take care that also the content of the string which specifies the name of the field variable is changed.
    I am wondering why one of the replies commented, why the name of a field variable is changed, it sounds to me that this is something which basically never happens. I don’t know, I think that this happens actually quite often and thanks to all these nice IDEs and their “rename” feature this is usually no problem. From time to time names of classes change, name of field change, yes, they are often even completely rewritten, new field variables come in some are deleted, whatever it is. The way I currently can access the name of a class makes the code safer, because when I consequently go with Class.class.getSimpleName I always know, that when I rename the class all these statements are changed too If I delete such a class, I at least get a compile error.
    My very simple issues is, that I think it would be nice to have the same comfort not only on a class level but also on the level of field variables, nothing more, nothing less.
    To be honest, I have not browsed the forum yet if such an issue was already raised by other people (I will do this now), but somehow it is hard to imagine, that I am the first one.
    Best regards.

  • Object Array Data Provider Refresh Possible bug

    Hello
    I am having a problem with Object Array Data Provider in terms that the table's data is not changed corectly after a request as expected, but after two requests.
    Steps to reproduce the bug:
    0. Create a new Visual Web project, call it 'test'.
    Set 'Bundled Tomcat ' or 'Sun 9' as deploy target server.
    Edit 'Page1' of the project.
    1. Create an Entity class, simple class that has only getters and setters with a few fields (lets say 'id' and 'name').
    2. In the SessionBean1 that is generated by the framework create an array of Entity class named 'entityArr', and getters and setters for this field.
    3. Add a new Array Object Data Provider on the page and set in its properties as array the array created in the previous step 'entityArr (SessionBean1)'.
    4. Add a new table component, and set as data provider the provider created in step 3.
    In the Table's Layout map the fields from the Entity class, and set whatever compnents you desire for each component's type or leave the default ones (Static Text).
    5. Add a 'property change trigger component' on the page. I called it like this because I tried the following :
    5.1 A text field and a button to submit the text value
    5.2 A Calendar component with autosubmit
    5.3 A DropDown with autosubmit.
    6. On the property change trigger component created at step 5 set a value_changed method that changes the the array that should be displayed by the table.
    For Example, for a DropDown component, you will have a method like this :
    public void dropDown1_processValueChange(ValueChangeEvent event) {
    String idStr = (String) event.getNewValue();
    System.out.println("Entity id :"+idStr);
    if(idStr .equals("item1")) {
    fillSessionBean1(true);
    else {
    fillSessionBean1(false);
    getSessionBean1().setItemName(idStr);
    private void fillSessionBean1(boolean fillValues) {
    Entity[] values ;
    if(fillValues) {
    values = new Entity[4];
    for ( int i=0;i<values.length; i++) {
    Entity entity = new Entity();
    entity.setDescription("Description "+i);
    entity.setName("Name "+i);
    entity.setId(i) ;
    values[i] = entity;
    else {
    //values = new Entity[0];
    values = null;
    getSessionBean1().setEntityArr(values);
    7. When running the program, if the selected is Item1, the table does not show the array set if on this branch.
    I am using :
    Netbeans 5.5 build 20061017100,
    Visual Web Pack 070104_2,
    Ent.Pack 20061212
    jdk 1.6.0
    Operating Systems : Both Linux Suse10 and Windows.
    If anyone has a solution for this please let me know.

    OK
    While no one responded, I had to think for myself.
    There is a bug in the code generated by netbeans or there is nowhere specified that if you attach an array to a data provider you will have to notify by hand the data provider that the array has changed.
    You will have to put this line that is generated in init function in your valuechanged functions :
    objectArrayDataProvider1.setArray((java.lang.Object[])getValue("#{SessionBean1.entityArr}"));
    I think this aproach is a little bit wrong, even it works.
    I believe the data provider should be notified the array has been changed.
    There could be a much more simple aproaches :
    1. In the code generated by netbeans, if you attach an array to a data provider the data provider will be notified after any set(Object[])
    2. The data provider could have a function so you will ne anle to attach to the data provider an Object (the session bean, in my case) and the name of the function that retrieves the array (in my case, 'getEntityArr') .
    The code generated by netbeans could add this function easily.
    Maybe there are any other better aproaches, and I might be wrong.
    It's good that it works.

  • Java object array

    Hi all,
    first of all let's see some lines of source code
    Foo.java
    public class Foo
    public Socket pSocket = null;
    public nPosition = 0;
    NewBie.java
    public class NewBie{
    public Foo[] m_Foo = null;
    private int m_FooCount ;
    public Init(int nFooCount)
    m_Foo = new Foo[nFooCount];
    m_FooCount = nFooCount;
    public Operate()
    int i = 0;
    for( i= 0; i< m_FooCount; i++)
    //follwing line will throw a exception
    m_Foo.pSocket..... //Here is some operations with m_Foo[i].pSocket
    Funny.java
    public class Funny
    public static NewBie m_pNewBie = new NewBie();
    public static void main(String argv[])
    m_pNewBie.Init(10);
    m_pNewBie.Operate();
    %>java Funny
    Failed I/O:java.lang.NullPointerException
    when I debug the program , seems m_Foo[i].pSocket in method Operate of NewBie object is null. I am puzzled, because I have created a NewBie object array with "new", why it still be null?
    Any one can give me a detailed explaination? Thanks a lot.

    Arrays contain references, not objects. You must initialize the references within the array to point to constructed objects. Otherwise, the references will be null:
    m_Foo = new Foo[nFooCount];
    // m_Foo[0] is currently null -- the reference does not point to any object
    m_Foo[0] = new Foo();
    // now m_Foo[0] points to an object so is not null

  • Fill and object array

    I have too many books and not enough understanding on this subject.
    I am trying to fill an object type array with values and am totally confused. In my application, I successfully create a constructor in one file and test the object with some values in another file. I have two objects for employee and would like to place the object values into an object array. There is plenty of information on int[] arrays, but little on object arrays.
    After I can do the array fill:
    I would like to provide object values with JOptionPane.
    Change the print display to show all array elements
    But one thing at a time.
    I was thinking that objects exist first, then are loaded or filled into an object array. I seem to misunderstand as I am not performing the array fill very well. Following a book example seems to confuse me only more.
    Thank you
    //emp.java
    import java.util.*;
    public class Emp {
       private int id;
       private String name;
       private double salary;
       public Emp(int ident, String nm, double sal) {
         id = ident;
         name = nm;
         salary = sal;
       // method raise salary by 5 percent
       double raise() { return salary * 1.05;} // ends raise method
       // setters and getters
       public String getName()              { return(name); }
       public double getSalary()            { return(salary); }
       public int getID()                   { return(id); }
       public void setName(String nm)       { name = nm; }
       public void setSalary(double sal)    { salary = sal; }
       public void setID(int ident)         { id = ident; }
    }The test file
    //EmpTest.java
    import javax.swing.JOptionPane;
    public class EmpTest {
       public static void main(String[] args_) {
                 // Create object based on EmployeeTest2 class
                 // to add employee data to the array called empArray
                 Emp emp1 = new Emp(1,"Smith",2000);
                 Emp emp2 = new Emp(2,"Jones",2500);
                 //test and confirm the objects emp1 and emp2
                     int i;
                     String n;
                     double s;
                     double newsal;
                     // get the salary after the 5 percent raise
                     i = emp1.getID();
                     n = emp1.getName();
                     s = emp1.getSalary();
                     newsal = emp1.raise();
                     System.out.println("object Employee 1 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: " + newsal);
                     i = emp2.getID();
                     n = emp2.getName();
                     s = emp2.getSalary();
                     newsal = emp2.raise();
                     System.out.println("object Employee 2 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: " + newsal);
         // get the number of employees with JOptionPane
         String employeeCountString = JOptionPane.showInputDialog(
             "Employee Database " +
             "\nEnter the number of employees: ");
         // convert into an integer empcount
         int employeeCount = Integer.parseInt(employeeCountString);
         // initialize the empArray.
         Employee2[] empArray = new Employee2[employeeCount];
         fill(empArray);
         printContents(empArray);
       } //end main method
       private static void fill(Object[] my_arr) {
           int i;
           for (i = 0; i < my_arr.length; i = i + 1) {
         // get the name from the keyboard
         String employeeName = JOptionPane.showInputDialog(
             "Enter the employee name: ");
             // do something here to set the array element to employeeName
         // get the salary
         String employeeSalaryString = JOptionPane.showInputDialog(
             "Enter the employee monthly salary: ");
         //convert into a double
         double employeeSalary = Double.parseDouble(employeeSalaryString);
            //do something here to set array for salary
              my_arr[i] = new Employee2(1,"S1",5); // temporary values here
           } //ends for loop
       } // ends method
       private static void printContents(Object[] the_arr) {
          int i;
          for (i = 0; i < the_arr.length; i = i + 1) {
            System.out.print("Element: " + i);
            //System.out.println(" has the value : " + the_arr);
    System.out.println(" has the value : " + i);
    } //ends for loop
    } // ends printContents method
    } // ends EmpTest class

    what's the matter ?
    Try this :
    import javax.swing.JOptionPane;
    public class EmpTest {
         public static void main(String[] args_) {
              // Create object based on EmployeeTest2 class
              // to add employee data to the array called empArray
              Emp emp1 = new Emp(1, "Smith", 2000);
              Emp emp2 = new Emp(2, "Jones", 2500);
              // test and confirm the objects emp1 and emp2
              int i;
              String n;
              double s;
              double newsal;
              // get the salary after the 5 percent raise
              i = emp1.getID();
              n = emp1.getName();
              s = emp1.getSalary();
              newsal = emp1.raise();
              System.out.println("object Employee 1 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: "
                        + newsal);
              i = emp2.getID();
              n = emp2.getName();
              s = emp2.getSalary();
              newsal = emp2.raise();
              System.out.println("object Employee 2 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: "
                        + newsal);
              // get the number of employees with JOptionPane
              String employeeCountString = JOptionPane.showInputDialog("Employee Database "
                        + "\nEnter the number of employees: ");
              // convert into an integer empcount
              int employeeCount = Integer.parseInt(employeeCountString);
              // initialize the empArray.
              Emp[] empArray = new Emp[employeeCount];
              fill(empArray);
              printContents(empArray);
         } // end main method
         private static void fill(Object[] my_arr) {
              int i;
              for (i = 0; i < my_arr.length; i = i + 1) {
                   // get the name from the keyboard
                   String employeeName = JOptionPane.showInputDialog("Enter the employee name: ");
                   // do something here to set the array element to employeeName
                   // get the salary
                   String employeeSalaryString = JOptionPane.showInputDialog("Enter the employee monthly salary: ");
                   // convert into a double
                   double employeeSalary = Double.parseDouble(employeeSalaryString);
                   // do something here to set array for salary
                   my_arr[i] = new Emp(1, employeeName, employeeSalary); // temporary values here
              } // ends for loop
         } // ends method
         private static void printContents(Object[] the_arr) {
              int i;
              for (i = 0; i < the_arr.length; i++) {
                   System.out.print("Element # "+i+" Name= "+ ((Emp)the_arr).getName());
                   System.out.print("Salary # "+i+" Salary = "+ ((Emp)the_arr[i]).getSalary());
              } // ends for loop
         } // ends printContents method
    } // ends EmpTest class

  • [svn:cairngorm3:] 15438: -Change initialization objects of Cairngorm Parsley extensions to Parsley convention  (i.e.

    Revision: 15438
    Revision: 15438
    Author:   [email protected]
    Date:     2010-04-15 03:39:34 -0700 (Thu, 15 Apr 2010)
    Log Message:
    -Change initialization objects of Cairngorm Parsley extensions to Parsley convention (i.e. CairngormModuleLib>CairngormModuleSupport). Every initialization object has a static initialize method and implements Parsley's ContextBuilderProcessor, which allows it to be specified within a ContextBuilder definition.
    -API Change in Navigation library: Changed -FirstEnter metadata to Enter(time="first"), -Enter metadata to Enter(time="next") and -EveryEnter metadata to Enter(time="every")
    -Added convenience isValid get accessor to ValidationGroupEvent
    Modified Paths:
        cairngorm3/trunk/libraries/IntegrationDMS/.flexLibProperties
        cairngorm3/trunk/libraries/IntegrationRPC/.flexLibProperties
        cairngorm3/trunk/libraries/IntegrationTest/src/CommandScopeSample.mxml
        cairngorm3/trunk/libraries/IntegrationTest/src/LocalConnectionConsumer.mxml
        cairngorm3/trunk/libraries/IntegrationTest/src/LocalConnectionProducer.mxml
        cairngorm3/trunk/libraries/Module/.actionScriptProperties
        cairngorm3/trunk/libraries/Module/.flexLibProperties
        cairngorm3/trunk/libraries/ModuleTest/.actionScriptProperties
        cairngorm3/trunk/libraries/ModuleTest/.flexProperties
        cairngorm3/trunk/libraries/ModuleTest/src/CairngormModuleLibRuntimeSample.mxml
        cairngorm3/trunk/libraries/ModuleTest/src/CairngormModuleLibSample.mxml
        cairngorm3/trunk/libraries/Navigation/.actionScriptProperties
        cairngorm3/trunk/libraries/Navigation/.flexLibProperties
        cairngorm3/trunk/libraries/Navigation/pom.xml
        cairngorm3/trunk/libraries/Navigation/src/com/adobe/cairngorm/navigation/landmark/Abstrac tNavigationDecorator.as
        cairngorm3/trunk/libraries/NavigationTest/src/NavigatorSample1.mxml
        cairngorm3/trunk/libraries/NavigationTest/src/ToggleButtonBarSample.mxml
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/contacts/BusinessContactsPM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/contacts/ContactsPM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/contacts/PrivateContactsPM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/ContentPM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/dashboard/DashboardFoo terPM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/dashboard/DashboardPM. as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/dashboard/NestedChild1 PM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/dashboard/NestedChild2 PM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/dashboard/NestedChildP M.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/messages/MessagesPM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/news/NewsPM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/tasks/ExpensePM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/tasks/TaskPM.as
        cairngorm3/trunk/libraries/NavigationTest/src/sample1/presentation/tasks/TimeTrackingPM.a s
        cairngorm3/trunk/libraries/ObserverParsley/.flexLibProperties
        cairngorm3/trunk/libraries/PersistenceTest/src/com/adobe/cairngorm/persistence/sample/pre sentation/CreateDatabasePM.as
        cairngorm3/trunk/libraries/PersistenceTest/src/com/adobe/cairngorm/persistence/sample/pre sentation/PeoplePM.as
        cairngorm3/trunk/libraries/Validation/src/com/adobe/cairngorm/validation/event/ValidatorG roupEvent.as
        cairngorm3/trunk/libraries/ValidationTest/src/SampleModelValidationWithCombos.mxml
        cairngorm3/trunk/libraries/ValidationTest/src/combo/ComboDomain.as
        cairngorm3/trunk/libraries/ValidationTest/src/combo/ComboDomainValidatorGroup.mxml
        cairngorm3/trunk/libraries/ValidationTest/src/combo/ComboPM.as
        cairngorm3/trunk/samples/insync/insync-basic/src/InsyncBasic.mxml
        cairngorm3/trunk/samples/insync/insync-modularExtended-contacts/src/ContactsModule.mxml
        cairngorm3/trunk/samples/insync/insync-modularExtended-shell/src/InsyncModularExtendedShe ll.mxml
        cairngorm3/trunk/samples/insync/insync-modularExtended-shell/src/insync/presentation/Expe nsesPM.as
    Added Paths:
        cairngorm3/trunk/libraries/IntegrationDMS/src/com/adobe/cairngorm/CairngormIntegrationDMS Support.as
        cairngorm3/trunk/libraries/IntegrationRPC/src/com/adobe/cairngorm/CairngormIntegrationRPC Support.as
        cairngorm3/trunk/libraries/Module/src/com/adobe/cairngorm/CairngormModuleSupport.as
        cairngorm3/trunk/libraries/Module/src/com/adobe/cairngorm/CairngormModuleXMLSupport.as
        cairngorm3/trunk/libraries/Navigation/src/com/adobe/cairngorm/CairngormNavigationSupport. as
        cairngorm3/trunk/libraries/ObserverParsley/src/com/adobe/cairngorm/CairngormObserverSuppo rt.as
    Removed Paths:
        cairngorm3/trunk/libraries/IntegrationDMS/src/com/adobe/cairngorm/CairngormIntegrationDMS Lib.as
        cairngorm3/trunk/libraries/IntegrationRPC/src/com/adobe/cairngorm/CairngormIntegrationRPC Lib.as
        cairngorm3/trunk/libraries/Module/src/com/adobe/cairngorm/CairngormModuleLib.as
        cairngorm3/trunk/libraries/Module/src/com/adobe/cairngorm/module/ModuleXMLSupport.as
        cairngorm3/trunk/libraries/Navigation/src/com/adobe/cairngorm/CairngormNavigationLib.as
        cairngorm3/trunk/libraries/Navigation/src/com/adobe/cairngorm/navigation/landmark/EveryEn terDecorator.as
        cairngorm3/trunk/libraries/Navigation/src/com/adobe/cairngorm/navigation/landmark/FirstEn terDecorator.as
        cairngorm3/trunk/libraries/ObserverParsley/src/com/adobe/cairngorm/CairngormObserverLib.a s

    Hi Karl,
    I'm sorry to barge into this dicussion. I've been trying to get in touch with you regarding Chrome Lib. Have sent a mail at the id given on the Chrome lib website. Kindly reply to that or give your mail id for contact.
    M Puns
    m_puns AT rediffmail DOT com

  • Search in object array

    I am working on a program in which one of the problems is to search an object array to allow a user to edit an item in the array. I have examples on how to do linear and binary searches, but they are all simple strings of numeric data. How do I apply this algorithm to a more complex array?I have a class file called Application that contains my constructor, and my get & set methods for creating the objects in the array. And I have a driver class to allow a user to view the array, add items to it , and edit items in it.
    This is an example of my declaration of the initial items:
    Application inventory[] = new Application[100];
      inventory[0] = new Application("Jumpstart Toddlers", 14.99, 500);
      inventory[1] = new Application("Norton Antivirus 2003", 49.99, 1200);
      etc....
    I would like to set it up so that the user is prompted for the name of the software item they would like to edit, the array is searched using a method which returns the index the name was found in.

    Sounds like a homework assignment to me but...
    Appliction apps[] = new Application[100];
    ...Add Items to the apps array...
    String software_to_search_for = .. user entered
    data....
    for (int i = 0; i < apps.length; ++i)
    if
    f
    (apps.getSoftware().equalsIgnoreCase(software_to_sea
    ch_for))
    edit(apps[i], software_to_search_for);
    public void edit(Application app, String newName)
    // You can do anything here
    app.setName(newName);
    } // edit
    True enough, this is an assignment. But..These assignments were given to us without all the necessary tools. They are set up by the dept. and we have to finish them even if the instructor does not finish covering all the relevant material.In this case, we have not covered the equalsIgnoreCase(something obviously necessary for my problem). Now that I know what I am looking for, I have found it in my book and can apply it to my code appropriately. I was not necessarily looking for code, just the tools I need for my own design. This is something that the Computer dept. allows for in that they have assistants in the open labs that will help in this manner. Problem is, everyone has been out for Thanksgiving since Tues. Please dont feel as though you assisted someone in cheating!! I can assure you, that is not the case here. Thank you for your help.

  • Create a tablespace without specifying the datafile path and name

    HI,
    Is it possible to create a tablespace without specifying the datafile path and name.
    For eg : if we just specify the tablespace name and the size of the datafile, the datafile should be created in a default location with default name? Is it possible?

    user13364377 wrote:
    HI,
    Is it possible to create a tablespace without specifying the datafile path and name.
    For eg : if we just specify the tablespace name and the size of the datafile, the datafile should be created in a default location with default name? Is it possible?Using Oracle-Managed Files
    Oracle internally uses standard file system interfaces to create and delete files as needed for the following database structures:
    * Tablespaces
    * Online redo log files
    * Control files
    Through initialization parameters, you specify the file system directory to be used for a particular type of file.
    EXAMPLE:
    The following parameter settings are included in the initialization parameter file:
    DB_CREATE_FILE_DEST = '/u01/oradata/sample'
    DB_CREATE_ONLINE_LOG_DEST_1 = '/u02/oradata/sample'
    DB_CREATE_ONLINE_LOG_DEST_2 = '/u03/oradata/sample'
    The following statement is issued at the SQL prompt:
    SQL> CREATE DATABASE sample;
    SQL> CREATE TABLESPACE tbs_2 DATAFILE SIZE 400M ;
    SQL> CREATE UNDO TABLESPACE undotbs_1;
    refer the link for more information:
    http://download.oracle.com/docs/cd/B10500_01/server.920/a96521/omf.htm

Maybe you are looking for

  • Logic Pro not working right:  HELP!!!!!!!

    Logic Pro is no longer sending audio signals to the mixer. The Output display is no longer available in the Mixer. Do I need to do a major reinstall of Logic from scratch? This was not my initial problem, but developed as I tried to "fix" a different

  • My cell phone number is not available for iMessage on the iPad

    My cell phone number is not available for iMessage on the iPad, it used to be available but now it is not and it won't let me add my phone number. My iMessage is working on my iPhone but not my iPad.

  • Leopard Not Seeing Correct Permissions on Files on Leopard Server

    File on OS X 10.4 server has the following permissions: owner abc read & write group abc read & write everyone read only If I connect to the server via AFP from a client running OS X 10.4 with user xyz that's in group abc, that client shows these per

  • Adobe Photoshop Album Mini 3.2

    以前表記の製品(試用版)を使っていたのですが.次のようなメッセージが表示され.「ロック解除コード」を入力しないと消去できません.ロック解除コードはありません.このような場合どのよう に対処すればよろしいでしょうか? 「試用期間が終了したので.このプログラムは使用できなくなりました.ご使用を継続される場合は.ユーザ登録を行ってソフトウェアのロックを解除してください.登録すると.使い方のヒントやテ クニック.製品及びサービスのアップグレード情報など.コンシューマー向けデジタル写真関連の情報がAdbe

  • Why can access the dynamic textField inside a Button?

    yep, I have another problem I create a button in the library, it has a background graphic on a layer and a textField, the textField has a instance name defined in the properties panels and some text. I manually place some instance of the button on st