Array of CreditCard objects - PLEASE HELP!

My situation is this: I need to create an array of CreditCard objects. The problem is that when I try to invoke the methods getName, getNumber, or getLimit, the compiler recognizes the array (cardholders) as a variable.
My coding is this.
for(int i=0;fileInput.hasNext();i++)
     CreditCard[] cardholders = new CreditCard[records];
     int cardNum = Integer.parseInt(fileInput.next());
     String cardName = fileInput.nextLine();
     double cardLimit = Double.parseDouble(fileInput.nextLine());
     cardholders[i] = new CreditCard(cardNum, cardName, cardLimit);
But when I try to access a CreditCard object, through cardholders[4] (for example), the error cannot find symbol appears. PLEASE HELP ITS DRIVING ME CRAZY.
THANKS

You are lacking basic Java knowledge, micksabox. The following tutorial is on Arrays in Java. The one after on the Java Collections Framework, you might want to learn about as the better solution for working with sets and lists of objects in Java.
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
http://java.sun.com/docs/books/tutorial/collections/index.html

Similar Messages

  • Creating an Array of external JPGs, please help.

    So what I want to do is load up external JPGs into an Array of MovieClips, and then go to the main onEnterFrame function. My code is below:
    var imageLoader:Loader = new Loader();
    var imageArray:Array = new Array();
    function loadImage():void {
        for (i = 0; i < 9; i++) {
            imageLoader.load(new URLRequest("image" + String(i) + ".jpg"));   
            imageArray[i] = new MovieClip();
            imageArray[i].addChild(imageLoader);
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    I tried adding an Event.COMPLETE function I found:
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
    function imageLoaded(e:Event):void {
         var image:Bitmap = (Bitmap)(e.target.content);
         imageArray[i] = new MovieClip();
         imageArray[i].addChild(image);
    Unfortunately, I usually only ended up with 1 or 0 images, and errors. I can't seem to properly pass the i
    value, so that's a big problem because the order the images go is key to my program.
    Please help me get this working so my image gallery can work, thanks!

    So the problem is that you want them in the array in the same sequence am I right on this?
    See the updated code:
    var imageArray:Array = new Array();
    var imageLoader:Array = new Array();
    function loadImage():void {
        for (i = 0; i < 9; i++) {
            var imageLoader[i] = new Loader();
            imageArray[i] = new MovieClip();
            imageLoader.load(new URLRequest("image" + String(i) + ".jpg"));   
            imageArray[i].addChild(imageLoader[i]);
            //imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    /* function imageLoaded(e:Event):void {
         var image:Bitmap = (Bitmap)(e.target.content);
         imageArray[index].addChild(image);
    In this case you can not track whether an image is loaded or not. It is the most simplest way of doing this. If your images are not coming from dynamic sources and are fixed in number and position you can use this method also.

  • JS CS5.5-Moving Selected Objects-Please Help!!

    Hello,
    I have a scritpt that will apply a certain object style to the selected items in the document. I am trying to add a "move" to this scirpt. I would like every item selected in the document to move down .125 inches. I know this is much simpler than I think it is, I've always had trouble with bounds in scripts. If anyone could please help me with this, I'd greatly appreciate it.
    Thanks for your time,
    Danny

    I suppose if I was going to be picky, I should have provided my code initially, rather than waiting for csm_phil and then posting something else. Anyhow, I think it is better to use:
    var
        i,
      savedUnits = app.scriptPreferences.measurementUnit;
    try {
      app.scriptPreferences.measurementUnit =
          MeasurementUnits.INCHES;
      for (i = 0; i < app.selection.length; i++){
          app.selection[i].move(undefined, [0, +.125]);
    } finally {
      app.scriptPreference.measurementUnit = savedUnits;
    This changes the scriptPreferences, not the viewPreferences, which means that even if you screw up and don't set it back, it does not affect the user. It also means it is one variable to change and not two. We take care to save the units and set them back, so other scripts and users are not affected.  We even use a try/finally block so that if an error condition is thrown by the move, we reset the measurement unit afterwards anyhow.
    Lastly, unlike csm_phil, I don't cancel the selection at the end. I didn't see Danny asking for that and I don't think it's what you would want.

  • Parse into array using JDOM! please help

    hey,
    i've managed to parse an xml document using JDOM
    i[b] need to be able to parse it and store the text (the value of each node) into an array, and then insert into db etc.
    the problem is with the recursive function listChildren which calls itself... can someone tell me where do i insert the block of code such that i can store it into an array of string.
    here's the code:
    public static void parse(String stock) throws SQLException
    SAXBuilder builder = new SAXBuilder();
    Reader r = new StringReader(stock);
    Document doc = builder.build(r);
    Element root = doc.getRootElement();
    listChildren(root, 0);
    public static void listChildren(Element current, int depth) throws Exception
    String nodes = current.getName();
    System.out.println(nodes + " : " + current.getText());
    List children = current.getChildren();
    Iterator iterator = children.iterator();
    while(iterator.hasNext())
    Element child = (Element) iterator.next();
    listChildren(child, depth+1);
    i'm looking for something like:
    a=current.getText();
    but i donno where to include this line of code, please help
    cheers,
    Shivek Sachdev

    hi, I suggest you make an array of byte arrays
    --> Byte[][] and use one row for each number
    you can do 2 things,
    take each cipher of one number and put one by one in each column of the row correspondent to that number. of course it may take too much room if the int[] is too big, but that is the easiest way I think
    the other way is dividing your number into bitsets(class BitSet) with sizes of 8 bits and then you can save each bit into each column of your array. and you still have one number in each row. To put your numbers back use the same class.
    Maybe someone has an easier way, I couldnt think of any.

  • Problem with array size...PLEASE HELP

    hi...
    I want to keep putting the Strings that user inputs, in an array. I don't know how many of them there are, and I don't want to define a big array like :
    String myArray[]= String [1000];
    what am I suppose to do?
    PLEASE HELP...!
    Thanks

    Use a Vector or an ArrayList instead of a straight array.

  • I know abap, want to know details on BO(Business Objects). please help me!!

    hi, I know abap, want to know details on BO(Business Objects) & its relationships with ABAP.
    i may learn BO or CRM. want ur ideas. please help me!!
    Thanks!
    -Parthi

    Please try to Post in Proper Thread
    If u  r trying to Learn SAP Bo Means
    Help.sap.com
    is the Best Sites for
    and Below Links it will become an Expert in Bo
    Assign Points if it Useful
    http://help.sap.com/businessobject/product_guides/
    http://www.sdn.sap.com/irj/scn/businessobjects-elearning
    Thank u

  • Arrays - confusing, wont compile, please help! ?:-)

    Hello everyone,
    I am new to the java forum, and I think its a fantastic idea. I am extremely stuck with my java, I have been workin on the same piece of code for at least 20 hours in total, 8 of which I spent in the last day, and to much of my frustration, the buggery code just wont compile. Im assuming many of you are probably laughing at me by now, lol, its ok, After my inital stress and hair pulling, all I could do was laugh. But I refuse to give up on the code after spending so long, and I have a feeling Im so close, its based around arrays, anyway I'll stop blabbering and post the code I have wrote, and if any of you could solve why it wont compile, it would be greatly appreciated.
    Heres my code:
    import avi.*;
    public class CDCollection
    private String title = "Unknown";
    private String artist = "Unknown";
    private int quan = 0;
    private double price = 0;
    CDCollection(double cdPrice, int cdQuan, String cdTitle, String cdArtist)
    title = cdTitle;
    artist = cdArtist;
    quan = cdQuan;
    price = cdPrice;
    return price;
    public static int findHighest(CDCollection[] cd) {
    int highestSoFar = -1; // lower than any valid
    for (int i = 0; i < cd.length; i++) {
    if (cd.CDCollection() > highestSoFar) {
    highestSoFar = cd[i].CDCollection();
    return highestSoFar;
    // instance method to write out cd details
    public void cdDetails(Window screen)
         screen.write("�"+price+"\t"+quan+"\t"+title+"\t"+artist+"\n");
    class CDMain
    public static void main(String[] args)
         Window screen = new Window ("CDMain", "bold", "black", 14);
    screen.showWindow();
         screen.write("CD List:\n\n");
              CDCollection cd1 = new CDCollection (10.99,11,"All Killer No Filler","Sum 41");
         cd1.cdDetails(screen);
    CDCollection cd2 = new CDCollection (12.99,8,"The best of","Sting");
         cd2.cdDetails(screen);
    Essentially wot Im tryin to do, is create a cd collection program, whereby details of the cd are entered (price, quantity, title and artist) and I would like to return statistical data on the cd collection, such as total number of cds, most expensive and cheapest cds etc. As you can I see I have tried to use arrays to find out the most expensive cd, but it still wont work! Please help, anyone, as Ive exhausted myself on this piece of code, Ive been through books, and I still cant bloody do it. :( lol
    Thanks in advance,
    All the best,
    Larry :-)

    Hi!
    First you never call your method findHighest.
    Second you do not have an array of your CD's. You only have two instances of it.
    Try this:
    CDCollection[] cds = new CDCollection[2];
    CDCollection cd[0] = new CDCollection (10.99,11,"All Killer No Filler","Sum 41");
    cds[0].cdDetails(screen);
    CDCollection cds[1] = new CDCollection (12.99,8,"The best of","Sting");
    cds[1].cdDetails(screen);
    int highest = CDCollection.findHighest(cds);
    And:
    public static int findHighest(CDCollection[] cd) {
    double highestSoFar = -1; // lower than any valid
    for (int i = 0; i < cd.length; i++) {
    if (cd.getPrice() > highestSoFar) {
    highestSoFar = cd[i].getPrice();
    return highestSoFar;
    And in your CDCollection class you need a method:
    public double getPrice()
    return this.price;
    I hope I did no mistake in here but it should work!
    Markus

  • How to properly create path art object, please help

    Hello there,
    I have a vector of AIRealPoint , each point is actual X, Y coordinate of the stroke. I need to create path art object out of this vector.
    I'm  somehow confused how to correctly construct segments array form the given AIRealPoints, my goal is to have single path object where count of segments is equal to count of AIrealPoints first and last points are anchors. SDK documenation is not really helping here...
    Please, take a look at the code snippet, it seems I'm doing something wrong with in and out params of segment , in any case I fail to create simple path object ....
    ASErr CretaeVectorPathTest2(vector<AIRealPoint>& stroke)
    AIArtHandle artHandle;
    ASErr result = kNoErr;
    try {
      AIRealPoint start;
      long lngStrokeLength = stroke.size()-1;
      AIArtHandle lineHandle = NULL;
      AIErr error = sAIArt->NewArt( kPathArt, kPlaceAboveAll, NULL, &lineHandle );
      if ( error ) throw( error );
      error = sAIPath->SetPathSegmentCount( lineHandle, lngStrokeLength );
      if ( error ) throw( error );
      AIPathSegment *segment = new AIPathSegment[lngStrokeLength];
      // This is a first point of the path
      segment[0].p.h = stroke[0].h;
      segment[0].p.v = stroke[0].v;
      segment[0].in = segment[0].out = segment[0].p;
      segment[0].corner = true;
      for(inti=1 ;i< lngStrokeLength-1;i++)
       segment[i].p.h = stroke[i].h ;
       segment[i].p.v = stroke[i].h ;
       // NOT GOOD!!!
       segment[i].in.h  = stroke[i-1].h ;
       segment[i].in.v  = stroke[i-1].v ;
       segment[i].out.h  = stroke[i+1].h;
       segment[i].out.v  = stroke[i+1].v;
       segment[i].corner = false;
    // NOT GOOD!!!
      // This is a last point of the path
      segment[lngStrokeLength].p.h = stroke[lngStrokeLength].h;
      segment[lngStrokeLength].p.v = stroke[lngStrokeLength].v;
      segment[lngStrokeLength].in = segment[lngStrokeLength].out = segment[lngStrokeLength].p;
      segment[lngStrokeLength].corner = true;
      error = sAIPath->SetPathSegments( lineHandle, 0, lngStrokeLength, segment );
      if ( error ) throw( error );
      error = sAIPath->SetPathClosed( lineHandle, false );
      if ( error ) throw( error );
    // apply color width etc.
      AIPathStyle style;
      error = sAIPathStyle->GetPathStyle( lineHandle, &style );
      if ( error ) throw( error );
      style.strokePaint = true;
      style.stroke.color.kind = kFourColor;
      style.stroke.color.c.f.cyan = 0;
      style.stroke.color.c.f.magenta = 0;
      style.stroke.color.c.f.yellow = 0;
      style.stroke.color.c.f.black = 100;
      style.stroke.width = 0.75;
      style.stroke.dash.length = 0;
      delete[] segment;
      error = sAIPathStyle->SetPathStyle( lineHandle, &style );
      if ( error ) throw( error );
    catch (ai::Error& ex) {
      result = ex;
    return result;
    Thanks,
    David

    As for beziers, Illustrator uses cubic beziers which are fairly straight forward (thank goodness!). Here's a lift from Wikipedia's Bezier entry:
    This image is pretty good at demonstrating how AI's bezier segments work. In the animation, the moving point has two lines sticking off it, ending with two points. If P3 was an AISegment, the left-hand blue point would be in and the right-hand point would be out. If we were to translate the state of the animation in its last frame into AI code, you'd basically have something like this:
    AISegment segment1, segment2;
    segment1.p = p0;
    segment1.in = p0;
    segment1.out = p1;
    segment2.in = p2;
    segment2.p = p3;
    segment.out = p3;
    Note that this would imply any line that continues beyond either end point isn't a smooth beizer curve (i.e. the curve is limited to between these points). That effectively makes them corner points (I think). Also, the line formed by linking in & p or out & p is the tangent to the curve at p, which I think you can make out from from the animation.
    Another way to get a feel for this is to use the pen tool to draw a line with a few segments. If you then pick the sub-select tool (white selection arrow, not black selection arrow) and select individual points on the curve, you'll see when you do that two 'anchors' jut out from each point. Those are the in & out for that point on the curve.
    Its all a little confusing because technically, a bezier segment between p & q would be p, p.out, q.in & q. (four vertices). To avoid repeating information, and keep it simple for non-beziers, AI's segments are still the vertices. So if you wanted to make the nth segment a beizer, you'd need n & n+1 from AI's path, and you'd modify two-thirds of each AISegment (p, out from n & in, p from n+1).
    I hope that helps, but if you have any further questions, feel free to ask! If you need to do anything fancy with beziers, there are some helpful utilites in AIRealBezier.h.

  • A dynamic table based on run-time created view object -- please help!

    Hello!
    I'm trying to create a dynamic table based on an run-time created view object. All go ok, but table binding component take the first view/iterator state and don't reflect changes they have. Please, take a look:
    1. At run-time the view is being replaced by new red-only one based on query in application module:
    getQueryView().remove();
    createViewObjectFromQueryStmt("QueryView", statement);
    2. Page definition file contains an iterator (using iterator or methodIterator - doesn't matter) binding and table, which binds to the iterator, like:
    <methodIterator id="distributeQuery1Iter" Binds="distributeQuery1.result"
    DataControl="QueryServiceDataControl" RangeSize="10"/>
    <table id="distributeQuery11" IterBinding="distributeQuery1Iter"/>
    3. The page code uses <af:table>. But, if I use table binding (it's right) like this:
    <af:table var="row" value="#{bindings.distributeQuery11.collectionModel}">
    <af:forEach items="#{bindings.distributeQuery11.attributeDefs}" var="def">
    the table will never changed (i.e. still show the first view instance).
    When I tried to use iterator binding directly (it's bad and cannot provide all needed features unlike CollectionModel from table binding) I saw that table works!
    (Code is somehing like:
    <af:table var="row" value="#{bindings.myIterator.allRowsInRange}">
    <af:forEach items="#{bindings.myIterator.attributeDefs}" var="def">
    Why the table binding do not reflect changes in iterator? Or should I use different approach?
    Thanks in advance!
    Ilya.

    I got it to work! I used a hybrid approach comprised of some of your code and some of Steve Muench's AcceessAppModuleInBackingBean example.
    In the setBindings method, I execute an app module method that redefines the query, then I used your code to delete and recreate bindings and iterator:
    public void setBindingContainer(DCBindingContainer bc) {
    this.bindingContainer = bc;
    rebuildVO();
    The rebuildVO() method looks like the code you provided in your example:
    private void rebuildVO() {
    DCDataControl dc;
    DispatchAppModule dApp;
    DCBindingContainer bc;
    DCIteratorBinding it;
    OperationBinding operationBinding;
    ViewObject vo;
    DCControlBinding cb;
    try {
    bc = getBindingContainer();
    dc = bc.findDataControl(DATACONTROL);
    dApp = (DispatchAppModule)dc.getDataProvider();
    // Execute App Module Method to rebuild VO based upon new SQL Statement.
    dApp.setDispatchViewSQL();
    vo = dApp.findViewObject(DYNAMIC_VIEW_NAME);
    it = bc.findIteratorBinding(DYNAMIC_VO_ITER_NAME);
    it.bindRowSetIterator(vo, true);
    // logger.info("Remove value binding...");
    cb = bc.findCtrlBinding(DYNAMIC_VIEW_NAME);
    cb.getDCIteratorBinding().removeValueBinding(cb);
    bc.removeControlBinding(cb);
    // logger.info("Creating new value binding...");
    FacesCtrlRangeBinding dynamicRangeBinding =
    new FacesCtrlRangeBinding(null,
    bc.findIteratorBinding(DYNAMIC_VO_ITER_NAME), null);
    // logger.info("Add control binding...");
    bc.addControlBinding(DYNAMIC_VIEW_NAME, dynamicRangeBinding);
    } catch (Exception e) {
    e.printStackTrace();
    And my App Module method that redefines the view object looks like this:
    public void setDispatchViewSQL() {
    String SQL =
    "begin ? := PK_BUsiNESS.F_GETDISPATCHVIEWSQL();end;";
    CallableStatement st = null;
    String ViewSQL = null;
    try {
    st = getDBTransaction().createCallableStatement(SQL,
    DBTransaction.DEFAULT);
    * Register the first bind parameter as our return value of type LONGVARCHAR
    st.registerOutParameter(1, OracleTypes.LONGVARCHAR);
    st.execute();
    ViewSQL = ((OracleCallableStatement) st).getString(1);
    findViewObject(DYNAMIC_VO_NAME).remove();
    ViewObject vo = createViewObjectFromQueryStmt(DYNAMIC_VO_NAME, ViewSQL);
    vo.executeQuery();
    } catch (SQLException s) {
    throw new JboException(s);
    } finally {
    try {
    st.close();
    } catch (SQLException s) {
    s.printStackTrace();
    When I run it I get my desired results. One thing I don't quite understand is why when the page is first rendered it shows the last set of records rather than the first. Now I have to figure out how to put navigation URLS in each of the table cells.
    Thanks for your help; I would not have gotten this far without it,
    Jeff

  • Exception in finding the Home object Please Help

    Hi All,
    I am learning EJB. I wrote a bean called Hello Bean(from examples) which just prints out Hello. I tried calling it from the client program and I get this exception
    javax.naming.NameNotFoundException: Unable to resolve HelloLocalHome. Resolved:
    '' Unresolved:'HelloLocalHome' ; remaining name ''
    at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundR
    equest.java:85)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
    ef.java:255)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
    ef.java:222)
    at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
    at $Proxy0.lookup(Unknown Source)
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at examples.HelloClient.main(HelloClient.java:21)
    The HelloClient code at line 21 where it threw me this exception is
    Object obj=ctx.lookup("HelloLocalHome");
    Can someone help me out with this.
    In the web logic server console I saw the bean deployed. I understand from that the bean is deployed. Please someone help me out in this.

    Hello Sir,
    Thanks for the reply.When I saw the web logic server console , in the EJB list I had my enterprise bean there. Infact I uploaded my bean from the console. Will you please clarify this .
    Thanks a lot
    shyam

  • Cannot resize CS2 objects, please help!

    Hello,
    I'm new to this forum, hopefully someone here can help me.  I have worked with every other version of Photoshop and have never had this issue.  I just installed (and updated) Photoshop CS2 for Windows.  When I attempt to do a simple resize of an image object, it doesn't work.  The diagonal arrow handler shows up and the bounding box changes as if it will transform, but dragging by the corners do nothing.  I've tried doing it manually, through the toolbar (Transform -> Scale, and Transform -> Free Transform), via CTL+T...nothing.  A couple of times it did allow me to resize but didn't want to let me when I held Shift to keep the ratio intact...but now it won't let me at all.
    The other thing it's doing is when I drag the image object to move it to the corner of the canvas, the image follows my mouse but when I let go to place it pops right back over to where it was, as if there is some hidden anchor.
    As a side note some days I have to open Photoshop several times before I can create a new image or open one, because when I try to nothing happens at all.  So I don't know if the image resizing & moving issues are part of this bugginess or if it's a result of some setting Photoshop employed in CS2.  I have all the Snap to options turned off and have looked all over for a setting that might be causing this, to no avail.

    Thanks, Bart - Yes, I did reset the preferences per FAQ's.  This morning I tried repairing the installation but the problems still existed.  I then completely uninstalled the program and reinstalled it fresh, ran all of the updates again, and tried to play around with the tools I was formerly unable to use.  Everything appears to now be working correctly (although I'm not 100% convinced yet!)  When I installed it the FIRST time, I walked away from my computer while it was installing the Adobe updates, and Windows rebooted on me due to automatic Windows updates.  I'm wondering if that somehow corrupted the installation, as I was having all of the following problems:
    -crop wouldn't work
    -clipboard wouldn't import things to paste most of the time, errors
    -transform and resize didn't work
    -problems creating new files or opening files (no response)
    -lasso would reset in the middle of tracing
    -paintbrush strokes would work and then disappear
    -clone stamp would start working then disappear
    -flatten image didn't work
    There was other random bugginess here and there.
    I will be using the program frequently today and will update this post at the end of the day with whether or not the problems seem to be gone for good after this morning's reinstall.

  • Flash Layers, Frames, Keyframes, Objects – Please Help

    I would appreciate someone's help! I am working on a class
    assignment and currently struggling w / adding objects to layers.
    When a new layer is inserted how do you get a blank screen (not a
    new scene) on which to add your new objects? Everytime I add a new
    layer, I see previous layers w/objects. I need blank screens with
    the new layers.

    Deb H;
    If I follow the question, I suspect you need to review how
    layers work
    in flash (although it's very similar to other graphic
    applications), because
    what you seek is not really possible. You can get a blank
    stage by working
    in a different timeline such as a movie clip, or by adding a
    new scene--but
    not by simply adding layers (unless you are hiding the
    existing content in
    that timeline in some way. -Tom Unger

  • Stringbuffer to Array....please help.

    Is it possible to convert a stringbuffer into a 2d array?? I have a stringbuffer that contains the data for the table, when you look at the stringbuffer it has columns and rows as well as column headers in it. Is it at all possible to turn that into a 2d array? and if not how about just an array?

    Here are some starting points. Until I know better what you want to do, it might be hard.
    1. StringBuffer is used to combine chars and Strings into one single String. Maybe a Vector is more what you want. If you know the number of columns, but not the number of rows, a Vector of String Arrays would work.
    Vector V = new Vector();
    String [] S = null;
    while( more rows ...)
         S = new String[columncount];
         for(int i = 0 ; i < columcount ;i++)
              S[i] = column i for this row;
         V.add(S)
    //to show
    for(int i = 0 ; i < V.size() ; i++)
         String [] S = (String[])(V.get(i));
         for(int j = 0 ; j < S.length ; j++)
              System.out.print(S[j] + "\t");
         System.out.println();
    //also look into
    String [][] S= new String[V.size()][];
    V.copyInto(S);2. If you do want StringBuffer, the you are talking about parsing it. Are these tab separated columns with line breaks between?

  • Please Help me on recreating deleted arrays

    Hi,
    I'm trying to recreate a deleted array as follows:
    array=null;
    Array array[] = new Array[100];
    addToArray("elem1","elem2","elem3");
    but doesn't work. I'm unable to recreate/populate the array. Can someone please help me with this?
    I declared the array null first because the array was previously existing.
    What I need to do is to be able to add array elements dynamically and delete some at the same time.
    Deleting some elements seemed to be a complicated process so I thought of deleting the entire array instead then just recreate it and populate with required elements. I should keep the same array name.
    Thanks!
    Anna

    array=null;
    Array array[] = new Array[100]; // on this line you declare the variable array once again : the compiler doesn't accept it.
    addToArray("elem1","elem2","elem3");
    What I need to do is to be able to add array elements
    dynamically and delete some at the same time. You can also give a look at the Collection
    http://java.sun.com/docs/books/tutorial/collections/implementations/general.html
    and especially the class "ArrayList" http://java.sun.com/products/jdk/1.2/docs/api/java/util/ArrayList.html
    This class provides methods to add, delete element and dynamically enlarge the array.
    Good luck

  • Please Help!!! Getting data to a table

    I am having real problems with this I want a table with a header which lists the contents of a file. In this file on each line there are the header titles eg each line is set out the same just containing different parameters etc Event No: 0     Time Elapsed: 1.0 Event String: Algoritm changed Parameter: algo: Monitoring
    In the table the constructor says Object [][] and Object [] please help how do I get my code to compile.
         FileReader file = new FileReader("c:\\projects\\FirstSupport\\logfile2.txt");
              BufferedReader inputfile = new BufferedReader (file);
              Object[] columnNames = {"Event No",
    "Time Elapsed",
    "Event String",
    "Parameter"};
              Object[] values;
              MessageFormat mf = new MessageFormat("Event No:{0,number} Time Elapsed: {1,number} Event String:{2} Parameter:{3,number}");
              text = "Event No: 0     Time Elapsed: 1.0 Event String: Algoritm changed Parameter: algo: Monitoring";
              while ((Line = inputfile.readLine()) != null);
                   System.out.println(text);
                   values = mf.parse(text);
                   int eventNo = ((Number)values[0]).intValue();
                   double time = ((Number)values[1]).doubleValue();
                   String eventString = (String)values[2];
                   int param = ((Number)values[3]).intValue();
    JTable table = new JTable(values,columnNames);

    Hi,
    where is the problem? Does the part reading the file work? If so I would use a class extending DefaultTableModel .
    Have a look at :
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    Phil

Maybe you are looking for