Reading arrays of objects

I am new to OCI programming, but have read the manuals on reading objects, but can not figure out how to do what I want to do from that documentation. I am using oracle 9.2.0.7
I have a package that produces a bunch of data. Currently this data is stored as records in local variables. From my understanding OCI can not read oracle records
so that I will need to change package to use either varrary or associative arrays. I do not want to place this data into a actual oracle table because the data only has meaning at time package procedure is run and then is out of date for any other purposes. I Only want to read the data that is created in sql packages so that my C program can do other work with that data. It will change data into an XML format that Internet Application will use.
This is where I am stuck, it is implied that OCI should be able to read these created arrays of objects, but all examples are reading oracle tables that have objects in them. So I would like either an example or some suggestions on how to get started on doing this. So far I have created and oracle object type that has my fields in it. Since I do not know how many records I will be creating when I
run this package I think I should put data in an associative array.

Hi
Yes, you'll need to publish the data somehow. One way to do it is to place the data into a PL/SQL collection; then select from that.
There's a write up of some examples at http://www.dbasupport.com/oracle/ora9i/cast.shtml
HTH
regards Nigel

Similar Messages

  • Reading a CSV file and producing an array of objects

    Hi everybody,
    I am writing an application which will read a cvs file and produce an array of objects.
    Can any body help me to solve this problem?
    Thanks
    Finny

    Hello,
    Have you tried this link?
    http://ostermiller.org/utils/CSV.html

  • Reading an Array of Objects from a .bin file!

    Hey, at the moment I'm creating a program whereby I write a set of objects onto a bin file, in this case an array of objects with a String name/county, and int population/area.... I'm not trying to read it back from the bin file and encountering trouble! I've managed to get it working using plain objects, however I want to be able to read in arrays of objects. The file itself compiles, however during running I get this error
    java.lang.NullPointerException
    at RecordFiles.CoastalRead.main(CoastalRead.java:33)
    at RecordFiles.__SHELL16.run(__SHELL16.java:6)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at bluej.runtime.ExecServer$3.run(ExecServer.java:774)
    Here is the program itself,
    import java.io.*;
    public class CoastalRead {
        public static void main(String[] args) {
            CoastalTowns towns[] = new CoastalTowns[50];
              towns[0] = new CoastalTowns();
              towns[1] = new CoastalTowns();
              towns[2] = new CoastalTowns();
              towns[3] = new CoastalTowns();
              towns[4] = new CoastalTowns();
              String name, county;
              int population, area;
            try {
                FileInputStream fileIn =
                        new FileInputStream("CoastalTownsBin.bin");
                ObjectInputStream in = new ObjectInputStream(fileIn);
                for (int i = 0; i < towns.length; i++){
                 towns[i] =(CoastalTowns) in.readObject();
                   System.out.println("Deserialized File...");
                       System.out.println("Name: " + towns.name);
              System.out.println("County: " + towns[i].county);
         System.out.println("Population: " + towns[i].population);
              System.out.println("Area: " + towns[i].area);
    in.close();
    fileIn.close();
    } catch (IOException i) {}
    catch (ClassNotFoundException c) {}
    +I'd appreciate a fast reply!+ And if someone needs the writing class I've used, I can post it asap.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    CoastalTowns towns[] = new CoastalTowns[50];
    towns[0] = new CoastalTowns();
    towns[1] = new CoastalTowns();
    towns[2] = new CoastalTowns();
    towns[3] = new CoastalTowns();
    towns[4] = new CoastalTowns();Why create an array with a size of 50 and then only fill 5 elements?
    Why bother filling any elements at all when you are reading the objects from a file?
    What happens if there are less than 50 objects in your file?
    I will assume CoastalTowns holds info about a single town, so why is it pluralised? Do you have a class called Dog or Dogs, Chair or Chairs, Person or People?
    } catch (IOException i) {}
    catch (ClassNotFoundException c) {}DO NOT swallow exceptions. At the very least put in a call to printStackTrace so you know if/when an exception occurs.
    I'd appreciate a fast reply!I typed as fast as I could but unfortunately I'm still and hunt and peck guy.

  • Formatted .data file, reading in and creating an array of objects from data

    Hi there, I have written a text file with the following format;
    List of random personal data: length 100
    1 : Atg : Age 27 : Income 70000
    2 : Dho : Age 57 : Income 110000
    3 : Lid : Age 40 : Income 460000
    4 : Wgeecnce : Age 43 : Income 370000
    and so on.
    These three pieces of data, Name,Age and Income were all generated randomly to be stored in an array of objects of class Person.
    Now what I must do is , read in this very file and re-create the array of objects that they were initially written from.
    I'm totally lost on how to go about doing this, I have only been learning java for the last month so anyone that can lend me a hand, that would be superb!
    Cheers!

    Looking at you other thread, you are able to create the code needed - so what's the problem?
    Here's an (not the only) approach:
    Create an array of the necessary length to hold the 3 variables, or, if you don't know the length of the file, create a class to contain the data. Then create an ArrayList to hold an instance of the class..
    Use the Scanner class to read and parse the file contents into the appropriate variables.
    Add each variable to either the array, or to an instance of the class and add that instance to the arraylist.

  • Displaying the contents of an array of objects

    Hello All,
    My Java teacher gave us a challenge and I'm stumped. The teacher wants us to display the contents of the array in the main menthod. The original code is as follows:
    public class TestObjects
         public static void main ( String args[] )
              Thing[] thingArray = { new Thing(4), new Thing(7) };
    }I understand that the elements of the array are objects, and each one has a value assigned to it. The following code was my first attempt at a solution:
    public class TestObjects
         public static void main ( String args[] )
              Thing[] thingArray = { new Thing(4), new Thing(7) };
                                    for ( int i = 0; i < thingArray.length; i++)
                                       System.out.println( thingArray );                         
    }To which I'm given what amounts to garbage output. I learned from reading about that output that its basically displaying the memory location of the array, and the the contents of the array. There was mention of overriding or bypassing a method in System.out.println, but I don't believe that we're that far advanced yet. Any thoughts? I know I have to get at the data fields in the objects of the array, but i'm not having an easy time figuring it out. Thanks very much in advance!

    robrom78 wrote:
    public class TestObjects
         public static void main ( String args[] )
              Thing[] thingArray = { new Thing(4), new Thing(7) };
    for ( int i = 0; i < thingArray.length; i++)
    System.out.println( thingArray );                         
    Note that you're trying to print the entire array at every loop iteration. That's probably not what you meant to do.
    You probably meant to do something more like
                                 System.out.println( thingArray[i] );Also, note that the java.util.Arrays class has a toString method that might be useful.
    To which I'm given what amounts to garbage output. It's not garbage. It's the default output to toString() for arrays, which is in fact the toString() defined for java.lang.Object (and inherited by arrays).
    I learned from reading about that output that its basically displaying the memory location of the array, and the the contents of the array.It displays a default result that is vaguely related to the memory, but probably shouldn't be thought of us such. Think of it as identifying the type of object, and a value that differentiates it from other objects of the same type.
    By the way I assume you mean "+not+ the contents of the array" above. If so, that is correct.
    There was mention of overriding or bypassing a method in System.out.println, but I don't believe that we're that far advanced yet. Any thoughts? No, you don't override a method in println; actually methods don't contain other methods directly. You probably do need to override toString in Thing.
    I know I have to get at the data fields in the objects of the array, but i'm not having an easy time figuring it out. You can get to the individual objects in the array just by dereferencing it, as I showed you above.
    But I suspect that won't be sufficient. Most likely, Thing doesn't have a toString method defined. This means that you'll end up with very similar output, but it will say "Thing" instead of "[Thing" and the numbers to the right of the "@" will be different.
    You'll need to override the toString() method in Thing to get the output you want.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Property List error: Unexpected character b at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.

    Hi,
    I have a MBP 13' Late 2011 and Yosemite 10.10.2 (14C1514).
    Until yesterday, I was using Garmin ConnectIQ SDK and all was working fine.
    Yesterday, I've updated my system with latest security updates and Xcode updates too (Version 6.2 (6C131e)).
    Since, I can't launch the ConnectIQ simulator app, I have this message in console :
    8/04/2015 15:19:04,103 mds[38]: There was an error parsing the Info.plist for the bundle at URL Info.plist -- file:///Volumes/Leto/connectiq-sdk-mac-1.1.0_2/ios/ConnectIQ.bundle/
    The data couldn’t be read because it isn’t in the correct format.
    <CFBasicHash 0x7fa64f44e9a0 [0x7fff7dfc7cf0]>{type = immutable dict, count = 2,
    entries =>
      0 : <CFString 0x7fff7df92580 [0x7fff7dfc7cf0]>{contents = "NSDebugDescription"} = <CFString 0x7fa64f44f0a0 [0x7fff7dfc7cf0]>{contents = "Unexpected character b at line 1"}
      1 : <CFString 0x7fff7df9f5e0 [0x7fff7dfc7cf0]>{contents = "kCFPropertyListOldStyleParsingError"} = Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it isn’t in the correct format." (Conversion of string failed.) UserInfo=0x7fa64f44eda0 {NSDebugDescription=Conversion of string failed.}
    I have looked at this file and it looks like a binary plist
    bplist00ß^P^V^A^B^C^D^E^F^G^H
    ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"$%&'()'+,^[\CFBundleNameWDTXcodeYDTSDKName_^P^XNSHumanReadableCopyrightZDTSDKBuild_^P^YCFBundleDevelopmentRegion_^P^OCFBundleVersi    on_^P^SBuildMachineOSBuild^DTPlatformName_^P^SCFBundlePackageType_^P^ZCFBundleShortVersionString_^P^ZCFBundleSupportedPlatforms_^P^]CFBundleInfoDictionaryVersion_^P^RCFBundleE    xecutableZDTCompiler_^P^PMinimumOSVersion_^P^RCFBundleIdentifier^UIDeviceFamily_^P^QDTPlatformVersion\DTXcodeBuild_^P^QCFBundleSignature_^P^ODTPlatformBuildYConnectIQT0611[iph    oneos8.1o^P-^@C^@o^@p^@y^@r^@i^@g^@h^@t^@ ^@©^@ ^@2^@0^@1^@5^@ ^@G^@a^@r^@m^@i^@n^@.^@ ^@A^@l^@l^@ ^@r^@i^@g^@h^@t^@s^@ ^@r^@e^@s^@e^@r^@v^@e^@d^@.V12B411RenQ1V14C109Xiphoneos    TBNDLS1.0¡#XiPhoneOSS6.0YConnectIQ_^P"com.apple.compilers.llvm.clang.1_0S8.1_^P^Tcom.garmin.ConnectIQ¡*^P^AW6A2008aT????^@^H^@7^@D^@L^@V^@q^@|^@<98>^@ª^@À^@Ï^@å^A^B^A^_^A?^AT^    A_^Ar^A<87>^A<96>^Aª^A·^AË^AÝ^Aç^Aì^Aø^BU^B\^B_^Ba^Bh^Bq^Bv^Bz^B|^B<85>^B<89>^B<93>^B¸^B¼^BÓ^BÕ^B×^Bß^@^@^@^@^@^@^B^A^@^@^@^@^@^@^@-^@^@^@^@^@^@^@^@^@^@^@^@^@^@^Bä
    I guess it is a normal format but my system seems to be unable to read binary plist ?
    I tried some stuff with plutil
    plutil -lint Info.plist
    Info.plist: Unexpected character b at line 1
    Same for convert
    plutil -convert xml1 Info.plist
    Info.plist: Property List error: Unexpected character b at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.
    I also try to download a fresh version of the connectIQ SDK and no changes.
    Any idea ?
    Thanks

    Step by step, how did you arrive at seeing this agreement?

  • Array of objects.....different syntax !!

    Both are Array of objects.........
    Object[] array  = new Object[2];
            array[0] = new Long( 1 );
            array[1] = new String( "My string" );Another code.........
    private Color colors[] =
             { Color.black, Color.blue, Color.cyan, Color.darkGray,
             Color.gray, Color.green, Color.lightGray,
             Color.magenta, Color.orange, Color.pink, Color.red,
         Color.white, Color.yellow };Both are array of objects. but look the difference one usues new another dont
    i dont like the second one.....but it is usued. what is it ?

    What I meant is you can always use the new operator to create an array. You can even use it in conjunction with populating it: Object[] = new Object[] {"foo", new Integer(5), etc...}; But more to the point, declaring an array final says nothing about that array's elements.
    public class ZZZ {
        final int[] arr_; // legal, as long as all ctors give this variable a value
        public ZZZ() {
            arr_ = new int[1]; // legal, even without providing a value for the element
        public ZZZ(int size) {
            arr_ = new int[size]; // legal
            arr_[0] = 0; // legal
            arr_[0] = 1; // legal
    }

  • Array of Object Refs

    I am doing exercises in a book (a couple books) to learn Java. I am a procedural pgmr and want to learn Java.
    Question 3 in Chapter 4 says:
    Create an array of object references of the class you created in Exercise 2, but don't actually create objects to assign into the array. When you run the program, notice whether the initialization messages from the constructor calls are printed.
    In exercise 2, I created an created an overloaded constructor. There are two constructors one that takes an argument and one that doesn't. I think I understand that I am being asked to look to see the values of the variables before the object is actually created but after initialization.
    My question is that I am not sure I understand what is being asked in question 3. I have to create an array of object references. I understand object references to be the varable names that hole the contents of the object. I don't understand what I am supposed to put into each (the two) elements of the array.
    Here is program written for exercise 2:
    //: c04:J402.java
    /* This has overloaded constructors. However, the argument must be given. Without it, there is an exception at runtime. */
    class Bird {
    Bird() {
    System.out.println("The object is an egg");
    Bird(String age) {
    System.out.println("The object is " + age + " months old");
    public class J402 {
    public static void main(String[] args) {
    String age = args[0];
    new Bird(age);
    } ///:~
    Thank you so much for any help.

    My question is that I am not sure I understand what is
    being asked in question 3. I have to create an array
    of object references. I understand object references
    to be the varable names that hole the contents of the
    object. I don't understand what I am supposed to put
    into each (the two) elements of the array.
    You need to make three different concepts clear to yourself: objects, object references, and reference variables.
    Objects are objects are objects. They are self contained entities that live somewhere in the memory. But, as you can't manipulate the memory directly (there are many good reasons for that), you can't manipulate objects directly.
    To get to objects you need references (or pointers). A reference is like a memory address. It normally points to the memory location of an object, but if the reference can also be a special 'null' reference that doesn't point to any object (or to every possible object, depending on how you want to look at it). The JVM takes care of talking to the underlaying object through the reference.
    An object can have many references pointing to it but a reference can point to only one object (or no / any object in the case of a null reference).
    Reference variables, then, are the ones you have in source code. Here's an example of a reference variable:Bird tweety;
    tweety = new Bird("I thought I saw a pussy cat!");(given a hypotetical class that can take a String object as an argument to the constructor)
    "tweety" is a reference variable. A reference variable is a variable that can hold a reference -- surprise! :). If not set to any particular reference, it's value may be null. If you now do something likeBird bird2 = tweety;
    tweety = new Bird();you first define a new ref. variable "bird2" and set its value to tweety's ref. Then you reset the var. tweety to point to a new Bird object. What happens to bird2? Nothing!! ... but if instead of "tweety = new Bird();" you had written "tweety.setChirp("TWEET!!!");" and then called bird2.chirp(), it would have chirped with "TWEET!!!" because the references of bird2 and tweety point to the same object.
    But, you can have references outside reference variables. In reference arrays (or "object arrays", the terminology can be confusing), for instance. Then, the codeBird[] flock = new Bird[2];0) Creates, allocates and initializes a new reference array object.
    1) Creates a new reference variable called "flock" and assigns it to a reference that points to the object that was created in 0).
    2) Creates 2 more references to Bird objects, initially set to null. No further objects are created. These references can be used like reference variables through flock[0] and flock[1].
    (not necessarily in this order)
    Now this should answer the excersise 3. The references of flock[0] and flock[1] are left as null and they don't point to any objects - They will only if you do something like "flock[0] = new Bird("chirp!");" or "flock[1] = tweety;"

  • Calling a Procedure which has Array of Objects as arguments (from BPEL)

    Hi,
    I wanted to pass multiple records as arguments to a stored procedure from BPEL.
    We created stored procedure which takes array of Objects as arguments. I invoked it from BPEL. It was successfully compiled and deployed.
    At runtime it is throwing following error.
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension">
    <part name="code">
    <code>17072</code>
    </part>
    <part name="summary">
    <summary>Error binding the value of a parameter. An error occurred when binding the value of parameter ARG in the SCOTT.TESTPACK.TESTPROC API. Cause: java.sql.SQLException: Inserted value too large for column: "sadfsafsad" Check to ensure that the parameter is a valid IN or IN/OUT parameter of the API. Contact oracle support if error is not fixable.</summary>
    </part>
    <part name="detail">
    <detail>Inserted value too large for column: "sadfsafsad"</detail>
    </part>
    </bindingFault>

    I think you from Sierra Atlantic and you using Beta 3. There was a bug in Beta 3 in using arrays, which got fixed in post Beta3. You got to wait till next release.

  • Placing an array of objects onto stage

    I am trying to place an array of objects onto a stage where they drop vertically. I have been able to do it by placing the array objects into an object called "bag" but have found that the bag object only contains the last array object id so I can not apply actions to various array objects.
    Also my objects do not loop and only appear once.
    Below is the code so far.
    var tempArray:Array = new Array(); // Stores randomised values
    var bagArray:Array = new Array("gslow_id","gshigh_id","glow_id","ghigh_id","gdiv_id",
      "gcall_id","gbust_id","gbull_id","gboom_id","gbear_id"); // List of bag names
    function createBags() {
    if (tempArray.length == 0) { // check if array is empty
         for (var i:Number = 0; i < targets; i++) { // for loop - creat variable bagName to the value of targets
         var bagName: String = bagArray[i];
         var depthLevel:Number = this.getNextHighestDepth();
         // attach movies to time line
         this.attachMovie(bagName, bagName, depthLevel, {_x:random(350) + 100, _y:random(0) + spacing});
         spacing += 45;
         tempArray.push(bagName);
         //trace(tempArray);
         bag = _root[bagName]; // create a bag object contain the bagName variable
         //trace (bag);
         bag.onEnterFrame = function() {
              if (this._x < 570 && this._y > 0) {
              this._y += speed * random(8);
              } else {
              this._x = random(500);
              } // end if (this._x < 570 && this._y > 0)
         } // end bag.onEnterFrame ()
    bag.onPress = function() {
    // if bag is pressed select action
    //trace (bag); 
    xPos = this._x
    yPos = this._y
    unloadMovie(this);
    score += 1000
    scoreText_txt.text = score;
    //trace(score);
    checkScore();
    } // end bag.onPress ()
    //trace(targets);
    //trace(bagName);
    } // end for (var i:Number = 0; i < targets; i++)
    } // end if (tempArray.length == 0)
    } // End createBags()

    try:
    var bagA:Array=[];
    var bagArray:Array = new Array("gslow_id","gshigh_id","glow_id","ghigh_id","gdiv_id",
      "gcall_id","gbust_id","gbull_id","gboom_id","gbear_id"); // List of bag names
    function createBags() {
    if (tempArray.length == 0) { // check if array is empty
         for (var i:Number = 0; i < targets; i++) { // for loop - creat variable bagName to the value of targets
         var bagName: String = bagArray[i];
         var depthLevel:Number = this.getNextHighestDepth();
         // attach movies to time line
         var bag:MovieClip = this.attachMovie(bagName, bagName, depthLevel, {_x:random(350) + 100, _y:random(0) + spacing});
      bagA.push(bag);
         spacing += 45;
         //trace (bag);
         bag.onEnterFrame = function() {
              if (this._x < 570 && this._y > 0) {
              this._y += speed * random(8);
              } else {
              this._x = random(500);
              } // end if (this._x < 570 && this._y > 0)
         } // end bag.onEnterFrame ()
    bag.onPress = function() {
    // if bag is pressed select action
    //trace (bag); 
    xPos = this._x
    yPos = this._y
    unloadMovie(this);
    score += 1000
    scoreText_txt.text = score;
    //trace(score);
    checkScore();
    } // end bag.onPress ()
    //trace(targets);
    //trace(bagName);
    } // end for (var i:Number = 0; i < targets; i++)
    } // end if (tempArray.length == 0)
    } // End createBags()

  • Creating a generic class with a constructor that takes an array of objects

    I am relatively new to java and want to build a quick utility class that can generate a Run Length Encoding of any object. The idea is to take an array of objects of type "O" and then encode a string of objects that are "equal" to each other as an integer that counts the number of such equal instances and a single copy of the instance. This has the potential to very quickly reduce the size of some objects that I want to store. I would like to implement this class as a generic.
    public class RunLengthEncoding<O> {
         private class RLEPair {
              private int length;
              private O object;
         public RunLengthEncoding(O[]) {
    }As you can see, I need to make a constructor that takes an array of type "O". Is this possible to do? I can't seem to find the right syntax for it.
    Thanks,
    Sean

    Sorry. Obvious answer:
    public RunLengthEncoding(O[] oarray) {Again, sorry for the noise.

  • How to list an array of objects using struts in jsp and ActionForm

    I am using the struts ActionForm and need to know how to display an Array of objects. I am assuming it would look like this in the ActionForm:
    private AddRmvParts addRmv[];
    But I am not sure how the getter and setter in the ActionForm should look. Should it be a Collection or an Iterator?
    I am thinking I need to use an iterator in the jsp page to display it.
    I am also wondering if the AddRmvParts class I have can be the same class that gets populated by the retrieval of data from the database. This class has 10 fields that need to display on the jsp page in 1 row and then multiple rows of these 10 fields.
    Thanks.

    Most probably the easiest way to make it accessible in your page is as a collection.
    ie
    public Collection getAddRmvParts()
    You can use the <logic:iterate> or a <c:forEach>(JSTL) tag to loop through the collection
    As long as the individual items in the collection provide get/set methods you can access them with the dot syntax:
    Example using JSTL:
    <c:forEach var="addRmvPart" items="${addRmvParts}">
      <c:out value="${addRmvPart.id} ${addRmvPart.name} ${addRmvPart.description}"/>
    </c:forEach>

  • Printing a listing from an array of objects

    I know I'm missing something simple here but for the life of me I can't spot it. The code below should print a list of student names to the screen. At the moment it only prints the last name entered into the array. I will kick myself when I see the answer but can anyone suss this out ? Many thanks for any help.
    // A Program called StudentDetails3.java which inserts student names into an array according to
    // a calculated hash Index and then prints out the name list in this order
    import javax.swing.JOptionPane;
    public class StudentDetails3
    // Member Section
    // Private members
    private static String studentName;
    // Public members
    public static String input = JOptionPane.showInputDialog(" Please enter the number of students in the class : - ");
    public static int maxNum = Integer.parseInt(input);
    public static int hashIndex = 0;
    // Constructor Section
    StudentDetails3 ( String newStudentName )
    studentName = newStudentName.toUpperCase();
    // Method Section
    public int hashCalc()
    int total = 0;
    for( int charNo = 0; charNo < studentName.length(); charNo ++ )
    char letter = studentName.charAt(charNo);
    int asciiVal = letter;
         if( studentName.charAt(charNo) ==' ')
         asciiVal = 0;
         total = total + asciiVal;
    hashIndex = total % maxNum;
    return hashIndex;
    public void output()
    System.out.println(" The student's name and hash index is " + studentName + " " + hashIndex );
    static class DetailsStorage
    // Member Section containing the array into which the student objects will be inserted
    private Object [] array;
    private int current;
    // Constructor
    DetailsStorage ( int noOfStudents )
    array = new Object[ noOfStudents ];
    current = 0;
    // Method for adding name to array
    public void add ( Object StudentDetails3 )
    {  if ( array [ hashIndex] == null )
    array [ hashIndex ] = StudentDetails3;
    else if ( (hashIndex + 1) <= (array.length-1) )
    do
    { hashIndex = ( hashIndex + 1 );
         if ( array [ hashIndex ] == null )
         {   array [ hashIndex ] = StudentDetails3;
         break;
    } while ( (hashIndex + 1) <= (array.length-1) );
         else
              for ( int firstLp = 0; firstLp < array.length; firstLp ++ )
         if ( array [ firstLp ] == null )
         {   array [ firstLp ] = StudentDetails3;
                   break;
    public void printOut ( )
    {   int loop = 0;
    System.out.println ( " Name\t\tCourse " );
    System.out.println ( "____\t\t_________ " );
         for ( loop = 0; loop < array.length; loop ++ )
         System.out.println ( ( ( StudentDetails3 ) array [ loop ] ).studentName );
    // Main Program for testing
    public static void main( String[] args )
    {   String  name;                                              
    // Obtain list of names from the user
    DetailsStorage nameList = new DetailsStorage( maxNum );
    for( int lp = 0; lp < maxNum; lp++ )
    {   name =  JOptionPane.showInputDialog(" Please enter the name of student in full ( e.g. Gareth Edwards )");
    StudentDetails3 newDetails = new StudentDetails3( name );
    newDetails.hashCalc();
         nameList.add ( newDetails );
    newDetails.output();
    nameList.printOut();
    System.exit(0);
    }

    You've made the student name a static field, which means that there's only one for the whole class.
    So the last one you input is the one you use for everybody.

  • Turning a resultset into an array of objects.

    First I will give some background on the situation...
    I have a table in which has many lines of data. Each line of data has a boolean (for a jcheckbox) we will call that "A" and then a bunch of other attributes that are related...we will call those B, C, and D. On a later screen there will be a reduced table in which has only the lines from the original table that were selected. This is why the whole row in the table has to be an object.
    So I have a query like this:
    ResultSet rs = stmt.executeQuery("SELECT A, B, C, D FROM tableName WHERE A= '1'");and then I would like to use:
    String ObjectRef;
                Boolean A;
                String B;
                String C;
                String D;
                while (rs.next()) {
                     A = rs.getString("A");
                     B = rs.getString("B");
                     C = rs.getString("C");
                    D = rs.getString("D");At this point I need to create an ArrayList or an Array of objects....each object having A, B, C, and D. how do I do that in this while condition?
    Or if someone knows a better way of goign about this please let me know. The main objective is to populate this table with objects containing each of of the above attributes. I tried to keep the scenario as simple as possible, so if it was confusing or I need to explain more, just ask.
    Thanks in advance.

    Atreides wrote:
    At this point I need to create an ArrayList or an Array of objects....each object having A, B, C, and D. how do I do that in this while condition?Create the list before you start the while loop. Then, inside the while loop, after extracting A..D, do something like this:
    MyClass mine = new MyClass(A, B, C, D); // or a no-arg c'tor and then a bunch of setters.
    list.add(mine);

  • Feeding an Array of Objects returned from a remote object using AMFPHP Remote procedure calls.

    Hi guys,
    I am working on an AIR Application that Uses Flex and AMFPHP remoting, The returned data type is an array of objects containing a sting an a url to an image on the server, How do bind this to a tilelist so i have a list with images representing the icons and the string representing labels of the Tilelist?

    We assume that the object have these two fields:
    -     label
    -     image
    so you may first pass the Array to the dataProvider of the TileList and make an ItemRenderer (with a label and a image). Then in the ItemRenderer, access to the objects fields with data:
    ItemRenderer.mxml
    <mx:VBox>
         <mx:Label text="{data.label}"/>
         <mx:Image source="{data.image}"/>
    </mx:VBox>

Maybe you are looking for

  • Lightroom JPEG files far larger than equivalent Photoshop files?

    I'm using Lightroom 2.3 on a Mac. If I take an image and export it from Lightroom as a JPEG at the 60 quality setting, the resulting JPEG is typically around 2-3 times larger than the same file saved from Adobe Photoshop CS3 using the High Quality se

  • [Win/CS3] Problem with tree view nodes display In Release Version of InDesign

    b [Win/CS3] Hi All, I am Facing a problem from last few days.I have a dialog on which i have a treeview ListBox.I am filling this listBox dynamically.On a Button click Event. My requirement is to show Some text value on the node and Index value on th

  • HP Battery, Is It OK to keep the charger plugged in ?

    Hi All This is my first question here and I hope you'll help me I want to ask if it is OK to keep the charger plugged in the laptop while the battery is full ? I mean when the battery is 100%, will the energy go directly to the PC or it will go to th

  • Using markers in the Sequence

    Thanks in advance. I have been reading various posts about this topic and thought I would ask again to see what works best. I work in animation and in the Avid, use Locators to put at the head of the scenes to identify all the shots. Then when I want

  • Concurrent request failed - emsg:was terminated by signal 10 SunOS SPARC

    I have a concurrent program working fine in text output but when i change the output to XML it failed. Log: Hora actual del sistema: 02-JUN-2010 17:52:51 +----------------------------- | Iniciando la ejecución del programa simultáneo... +------------