Initializing an array

I have an array that needs to be initialized 1096 times, I
don't want to use a cfloop because I am looking for a better
performance. So I use a query that brings all the records that have
been initialized, the problem is if some of them hasn't been
initialized and I use some conditionals as CFIF the application
will throw an error because the specified position into the array
doesn't exist yet.
Here's my code.
<cfquery name="lista_espacios"
datasource="#Application.BD#">
SELECT ISNULL(id_espacio,0) as id_espacio, ruta, url, alt
FROM ESPACIOS
ORDER BY id_espacio
</cfquery>
<cfloop query="lista_espacios">
<cfset lista[lista_espacios.id_espacio][1] =
lista_espacios.id_espacio>
<cfset lista[lista_espacios.id_espacio][2] =
lista_espacios.ruta>
<cfset lista[lista_espacios.id_espacio][3] =
lista_espacios.url>
<cfset lista[lista_espacios.id_espacio][4] =
lista_espacios.alt>
</cfloop>
<cfset cont=1>
<cfif #lista[cont][1]# EQ #cont# ><a
href="#lista[cont][3]#" onclick="abrirURL(#lista[cont][1]#);"
target="_blank"><img style="border:0px" width="13"
height="13" src="#lista[cont][2]#" title="#lista[cont][4]#"
alt="#lista[cont][4]#" />
</a>
<cfelse>
<img width="13" height="13" src="img/bad.jpg" />
</cfif>
<cfset cont = #cont#+1>

quote:
Originally posted by:
Newsgroup User
If I understand your requirements you have a database that
has some
records, but not necessarily all 1096 records at this time.
You want to
pull out these records, but have a full set of 1096 records
even if some
of them do not yet exist in the dataset.
There are database tricks that can be used to create a record
set like
this. Hopefully somebody will chime in with the details. This
would
greatly simplify your processing after that.
There is not enough information to know what approach would
be most appropriate.
What is the database type? Also, do the existing records have
sequential values for idespacio, starting with 1?

Similar Messages

  • Initializing object array

    Hi,
    I am having problem initializing object array - here is my scenario -
    I have created class a -
    public class A {
    Public String a1;
    Public String a2;
    Public String a3;
    }the I have created class b
    public class B {
    Public A [] aa;
    }and I want to initialiaze my class bi in anoither clas c
    public class C{
    A ar = new A;
    ar.aa[0].a1 = "test"
    }this gives me null ..please anybody help me
    Neha
    }

    Thanks for the reply ..I know this is not good code ..but I have to write the classes in this way in SAP to create the Webservice ...the SAP side understand this type of structure only ..I still got the same error ..here are my original classes -
    public class GRDataItem {
         public String AUFNR ;
         public String EXIDP ;
         public String EXIDC;
         public String MATNR ;
         public String WERKS ;
         public String CHARG ;
         public String VEMNG ;
         public String VEMEH ;
         public String CWMVEMEH ;
         public String CWMVEMNG ;
         public String STATUS;
    public class GRDataTab {
         public GRDataItem [] grItem;
    Public class webservice {
                int sn = 20 ;
                  GRDataTab tab = new GRDataTab();
                tab.grItem = new GRDataItem[sn];
                tab.grItem[1].AUFNR = "12";
    }Thanks for all your help
    Neha

  • Initializing string array registers

    Hello. I have posted my project. It is not even close to finished but I am having trouble initializing the array's labeled "Up values" and "Down values", to "0" for all elements, at beginning of Vi run. So, when I am at the Front Panel and running the Vi, I would like all of the fields to begin with a "0", the moment the Vi is started. I have tried a couple different things I could think of and watched the Core 1 Video about arrays again however, it doesn't give the example for a string and nothing I have tried so far, is working. Thank you.

    crossrulz wrote:
    There are a few options to you:
    1. Use an initialization state to write to your indicators their default values via a local variable
    2. Put the default values into the indicators and then right-click on them and choose Data Operations->Make Current Value Default.  This will store the default value in the indicators themselves.
    I would recommend going with #1.
    2. Put the default values into the indicators and then right-click on them and choose Data Operations->Make Current Value Default.  This will store the default value in the indicators themselves. I put a "0" in each field, I slected "make current value default, but after the Vi ran, and then I started the Vi again, it keeps the numbers in the registers that are left over from the previous test. I also tried your suggestion #1. however, it still isn't writing a "0" in all the fields. The reason for this is that I don't want the operator's to read old data accidentally, when the Vi is running. I thought if I wipe all the registers out, it will prevent that from happening.

  • Initializing an array of clusters in a CIN?

    I'm trying to write a CIN to connect to a mySQL database, retreive some information, and return it to labVIEW for display. The connection works perfectly using ODBC, but I'm having major trouble getting the information back to LabVIEW. I'm new to CINs and I'm still slightly confused as to how the different structures work. I want to return the data in an array of clusters (using struct names, a 'Set' of 'Records'). LV generated the structs, and I simply renamed some of the fields/names. The code I have so far works up to the point specified in the source below, when I try to initialize the array for data entry. I think what's throwing me off is the conplexity of my structures. Since it's an array of clusters, and not an array of say strings or integers, I'm getting confused. If anyone could help me out by telling me what's wrong with my code, and/or filling in the section of the while loop I'm rather clueless on.
    typedef struct {
    LStrHandle Number;
    LStrHandle SerialNumber;
    } Record;
    typedef struct {
    int32 dimSize;
    Record ptr[1];
    } Set;
    typedef Set **SetHdl;
    MgErr CINRun(COpt *ConnectionOptions, LStrHandle *Number, SetHdl *RecordSet);
    MgErr CINRun(COpt *ConnectionOptions, LStrHandle *Number, SetHdl *RecordSet)
    // LV error code
    MgErr err = noErr;
    // ODBC environment variables
    HENV env = NULL;
    HDBC dbc = NULL;
    HSTMT stmt = NULL;
    // Connection options data variables
    UCHAR* dsn = malloc(SQL_MAX_DSN_LENGTH * sizeof(UCHAR));
    UCHAR* user = malloc(32 * sizeof(UCHAR));
    UCHAR* pass = malloc(32 * sizeof(UCHAR));
    UCHAR* num = malloc(16 * sizeof(UCHAR));
    // Query variables
    INT qlen;
    INT nlen;
    UCHAR colNumber[5];
    SDWORD colNumberSize;
    UCHAR* query;
    INT numRows;
    // ODBC return code storage
    RETCODE retcode;
    /** Prepare data from LV for C++ manipulation **/
    strcpy(dsn, LStrBuf((LStrPtr)(*(ConnectionOptions->DSN))));
    dsn[(*(ConnectionOptions->DSN))->cnt] = '\0';
    strcpy(user, LStrBuf((LStrPtr)(*(ConnectionOptions->Username))));
    user[(*(ConnectionOptions->Username))->cnt] = '\0';
    strcpy(pass, LStrBuf((LStrPtr)(*(ConnectionOptions->Password))));
    pass[(*(ConnectionOptions->Password))->cnt] = '\0';
    strcpy(num, LStrBuf((LStrPtr)(*Number)));
    // Program crashes here too, but that's the least of my concerns right now. Keep reading down.
    //num[(**Number)->cnt] = '\0';
    qlen = (int)strlen(
    "SELECT m.Number FROM master AS m WHERE (m.Number LIKE '');"
    nlen = (int)strlen(num);
    query = malloc((qlen + nlen + 1) * sizeof(UCHAR));
    sprintf(query,
    "SELECT m.Number FROM master AS m WHERE (m.Number LIKE '%s'\0);",
    num);
    // Prepare and make connection to database
    SQLAllocEnv (&env);
    SQLAllocConnect(env, &dbc);
    retcode = SQLConnect(dbc, dsn, SQL_NTS, user, SQL_NTS, pass, SQL_NTS);
    // Test success of connection
    if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
    retcode = SQLAllocStmt(dbc, stmt);
    retcode = SQLPrepare(stmt, query, sizeof(query));
    retcode = SQLExecute(stmt);
    SQLBindCol(stmt, 1, SQL_C_CHAR, colNumber, sizeof(colNumber), &colNumberSize);
    SQLRowCount(stmt, &numRows);
    //Program crashes on the following line. I get an error in LV saying something about an error in memory.cpp
    DSSetHandleSize((*RecordSet), sizeof(int32) + (numRows * sizeof(Record)));
    (**RecordSet)->dimSize = numRows;
    retcode = SQLFetch(stmt);
    numRows = 0;
    while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
    /* Need code here to retreive/create Records and put them in the array */
    retcode = SQLFetch(stmt);
    numRows++;
    SQLDisconnect(dbc);
    else
    // Free ODBC environment variables
    SQLFreeConnect(dbc);
    SQLFreeEnv(env);
    // Return LV error code
    return err;

    This looks incorrect:
    MgErr CINRun(COpt *ConnectionOptions, LStrHandle *Number, SetHdl *RecordSet)
    Did you let LabVIEW generate the C file??
    When you pass an array of clusters to a CIN, what is passed is a handle to the array. You are declaring a pointer to a handle. I just did a test passing an array of clusters to a CIN. The C file looks like this (comments are mine):
    typedef struct {
    int32 Num1;
    int32 Num2;
    } TD2; // the cluster
    typeDef struct {
    int32 dimSize;
    TD2 Cluster[1];
    } TD1; // the array
    typeDef TD1 **TD1Hdl; // handle to the array
    CIN MgErr CINRun(TD1Hdl Array);
    Notice that it passes you a HANDLE, not a pointer to a handle.
    On this line:
    DSSetHandleSize((*RecordSet), sizeof(int32) + (numRows * sizeof(Record)));
    If RecordSet is a HANDLE, then (*RecordSet) is a POINTER - you are passing a POINTER to a routine that expects a HANDLE.
    The line:
    (**RecordSet)->dimSize = numRows;
    Is also incorrect - if RecordSet is a HANDLE, then (*RecordSet) is a POINTER, and (**RecordSet) is an ARRAY, but you're asking it to be a pointer. (*RecordSet)->dimSize would be the size to fetch.
    Read the rules again on what is passed to CINs.
    I strongly suggest developing the interface first - the VI that calls the CIN. Put the CIN in place and let LabVIEW generate the initial C file.
    Then modify the code to do something simple with the input arguments, like fetch the array size, and put this number into an output argument. Something VERY basic, just to test the ins and outs. Debug this until all ins and outs are working.
    THEN AND ONLY THEN add code to do whatever work needs doing.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Initializing an array question

    if i wanted to initialize elements of an array and get input from the user of how many there will be. where can i find some info on this?
    basically instead of initializing 0,1,2,3, and so on i wanted to do it in a for loop, but i have tried it a couple of different ways with no luck.
    maybe you guys can give me some insight on how i need to set this thing up or what i need to think about or where some of the reading is?
    any info would help
    thanks in advance guys

    well here is the code for it i thought i was intializing it correctly??
    public static void main(String[] args) {
            int y;
            int x;
            int maxValue = 0;
            int numRepitions;
            int [] counters = new int[maxValue];
            Scanner keyin = new Scanner(System.in);
            Random generator = new Random();
                System.out.println("please enter how many random numbers you would like to generate");
                maxValue = keyin.nextInt();
                System.out.println("please eneter how many values your would like to draw for");
                numRepitions = keyin.nextInt();
                for(y = numRepitions - 1; y >= 0; y--)
                   counters[y] = numRepitions;
                   counters[numRepitions]--;
           

  • Methodology Question: Initializing Static Arrays

    After almost gnawing my arm off in frustration, I finally stumbled onto how to go about initializing and populating a static array that's outside of my Class's constructor (by placing it inside of a static block). My problem is, I just don't understand why I needed to do it that way. My code started out as such:
    public class Parameter {
         private static appEnvironmentBean[] appEnvironment = new appEnvironmentBean[8];
         appEnvironment[0].setMachineIP("192.168.1.100")
    }and this kept throwing an error " ']' expected at line ###"
    so I changed it to this:
    public class Parameter {
         private static appEnvironmentBean[] appEnvironment = new appEnvironmentBean[8];
         static {
         appEnvironment[0].setMachineIP("192.168.1.100")
    }and it worked. Now my problem is, I'm assigning a literal, and I declared the Bean array as static, so the way I see it, there was no reason to throw assignments to the array inside of a static block. I'll take it as a "That's just the way it is" thing, but if someone out there could explain the reasoning behind having to put my assignments inside of a static block, it would really be appreciated.
    Thanks!

    Because if you didn't put it inside a static block you'd be attempting to execute code outside of a method which is illegal except for initialization.
    I think you could do it this way:
    private static appEnvironmentBean[] appEnvironment = {
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100") };it depends on whether setMachineIP returns an appEnvironmentBean.

  • Stalling a form from loading until the initial javascript arrays are loaded

    I am looking for a way to get a form to be hidden based on the onload event. I would like to call a javascript function to initially populate some select boxes based on javascript arrays, but I would like this to happen before the page loads or at least stall displaying the select boxes until they are populated.
    The way it is setup now, when the page loads, the select boxes try to load first and then the rest of the form loads. I would like to know if there is a way to load the select boxes from the javascript arrays, then have the select boxes and other form elements show up at the same time. I have tried putting a <div> around the entire form and within the javascript populate function I first use "document.formname.div_id.style.visibility=hidden" then at the end of the select box population within the function, I use "document.formname.div_id.style.visiblity=visible". I tried this and the select boxes appear blank; it is as if the populate function doesn't work at all.
    I realize this is a very long question, but I will award you Duke Dollars if you help me out!!!

    right now, I have it set up where I click on a link which is a jsp page which forwards me to the jsp page that has all the html in it. That page is where I initially try to populate the select boxes with the javscript arrays...I also have a number of javascript functions which change the contents of the select boxes based on another select box in the form. Will i have access to those "java" arrays, [instead of using the javascript arrays], that you are suggesting in the javascript code? I do need to use whatever arrays I create in javascript functions.

  • Initializing a array of elements

    long[] ids
    want to initialize ids to 0
    how to do that??
    Thanks.

    getting compilation error that array might not have
    been initialized.Then your code didn't necessarily create an array. You probably have something like this:
    long[] ids; <-- not assigned (yet)
    if (condition1) {
    ids = new long[42]; <-- assigned here, but conditionally
    ids[0] = 0; <-- oops - ids might not have even been initialized at all!

  • Initializing an array of generics

    Hello all,
    I have declared an array of Vector with generics. The declaration is OK but the initialization gives me an error.
    This is the declaration
    Vector<Integer>[] x;This must be an array. Each element of the array is of type Vector<Integer>.
    I tried to initialize it using the line
    x = new Vector<Integer>[4];but it didn't work.
    I also tried
    x = new Vector[4]<Integer>;but didn't work also. The only initialization that worked is
    x = new Vector[4];But I want to put the generic tag in the initialization because it gives me warning.
    Any suggestions?
    Regards,
    Ahmed Saad

    x = new <Integer> Vector[4];When I compile that with Sun's javac compiler, I
    still get a warning.
    If you are not, it's a bug in the compiler you are
    using.
    As far as I know, the code above is no different
    from:
    x = new  Vector[4];
    yeah, I am trying to solve the same problem, and despite the person posting it worked, it didn't get rid of the problem for me...
    private Vector<Object> [] data;
    X.java:nn: generic array creation
    this.data = new Vector<Object>[2];
    X.java:nn: warning: [unchecked] unchecked conversion
    found : java.util.Vector[]
    required: java.util.Vector<java.lang.Object>[]
    this.data = new Vector[2];
    X.java:nn: warning: [unchecked] unchecked conversion
    found : java.util.Vector[]
    required: java.util.Vector<java.lang.Object>[]
    this.data = new <Object>Vector[2];
    ^

  • Initializing an array of 13 button objects - a more compact way?

    This works, but I was wondering if there was a more compact syntax for what I am doing.
    I'm creating an array that contains 13 UIButton objects as follows:
    NSArray * myButtonObjects;
    myButtonObjects = [NSArray arrayWithObjects: [UIButton buttonWithType:UIButtonTypeRoundedRect],
    [UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
    [UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
    [UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
    [UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
    [UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
    [UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect], nil];
    Is there a shorter way of doing this, like specifying the number of UIButton objects I want to create the NSArray with?
    Thanks,
    doug

    Since my first long statement where I repeated the UIButton object 13 times worked, I thought this would work as well:
    NSArray *theButtons;
    for (i=0; i<13; i++) {
    [theButtons arrayByAddingObject:[UIButton buttonWithType:UIButtonTypeRoundedRect]];
    That compiles, but it doesn't work like the original. The program crashes when it tries to run that loop.
    doug

  • Initializing 3D array

    I wonder why the class won't compile. If I delete one [] and the 7, 8, 9 line it works fine. The error report says "incompatible class" and "found int, expected int[]".
    Does this become an improper initialization when one goes from 2D to 3D?
    Thanks
    //MultArray
    import java.util.*;
    public class MultArray {
    public static void main(String[] args) {
    int [][][] a1 = {
    {1, 2, 3, },
    { 4, 5, 6, },
    { 4, 5, 6, },
    }

    Does this become an improper initialization when one
    goes from 2D to 3D?the way you have it written... yes.
    here is the modified code that will compile.
    note the nesting to the third level.
    public static void main(String[] args) {
        int [][][] a1 = {
          {{1,2},{3,4}},
          {{5,6},{7,8}},
          {{9},{10}}
      }to break it down
    int[][][] a1 = { //first bracket opens array 1 level
    {{1,2},{3,4}} // second bracket array 2nd level 3rd brackets store each two elements in third levela1[0][0][0] = 1;
    a1[0][0][1] = 2;
    a1[0][1][0] = 3;
    a1[0][1][1] = 4;
    and so on...

  • Initializing array of user-defined class

    I have a need to make an array of my own classes, simply to make a database organized.
    First, I defined my class at the start of the program:
    public class FBase
    String FName = "";
    String FDate = "";
    int FNameLength = 0;
    int FDateLength = 0;
    int status = 0; // value of 0, 1, 2
    } FExample = New FBase;
    This gives me one instance of the class, FExample.
    Now I can store data thus:
    FExample.FName = "Jones";
    FExample.FDate = "1934";
    FExample.FNameLength = 5;
    FExample.FDateLength = 4;
    FExample.status = 2;
    What I would like is an array of such instances of this class.
    I have followed the standard procedure for initializing an array, but my efforts are not accepted.
    In place of the line above initializing one instance in FExample, I have tried -- both at the top of the program and in public void init() -- the following code:
    FBase[] Example = New FBase[200];
    FBase Example[] = New FBase[200];
    FBase[] Example;
    Example = new FBase[200];
    None of these are accepted. How do I do this?

    Alright -- I found one problem and solved it, but I still have another problem, pretty much the same problem I thought I was facing at the start, but now a little better defined.
    At first, my class did not work even with one instantiation, let alone when I tried to instantiate an array of the class. I dound that I did not have a constructor, and I need a constructor if I am to create an instance of the class (I am learning ...). So, the class now looks like this:
    public class FBase
    String FName = "";
    String FDate = "";
    public FBase(){} // constructor
    Now the following line of code works:
    FBase FExample = new FBase();
    I am able to use FExample.FName and FExample.FDate as proper variables.
    My problem still exists when I try to instantiate an array of the class. In place of the above line of code, I have tried this:
    FBase[] FExample = new FBase[200];
    The compiler accepts it, but now FExample[0].FName and FExample[0].FDate are not recognized as proper variables, and nothing goes on when I try to use them in the program.
    Any ideas?
    Edited by: vanhoey on Jun 27, 2008 12:38 PM
    Edited by: vanhoey on Jun 27, 2008 12:40 PM

  • Array elements keep returning to their initial value after being replaced

    Hello,
    This is my first post here, but this looks like a great place to discuss labview.
    I have a strange problem that probably has a simple answer.
    Basically, I have initialized an array outside of a "for loop" that contains a "flat sequence structure."  I use the array inside the flat seq structure, replacing elements within the array, incrementaly by 1 starting with index 0, so i have run a wire through the "for loop" barrier and then through the "flat seq structure box".
    However when I step through my VI what happens is this.
    On the first run through, it succesfully changes the element at index 0.  On the next iteration it succesfully replaces the element at index 1, however, now index 0 has returned to its initial value!   .... This continues.... say im up to my 100th iteration, all the previous indexes have all returned to their initialized value but index 99 (its the 100th iteration) now has the value it should...however on the next iteration, index 99 will return to its initialized value.... its a vicious cycle..
    Can anybody tell me what I've screwed up?
    Thanks a Million,
    Nick

    Are you using a shift register on your loop or a tunnel?  If you are using a tunnel, then the orginal value is always passed into the loop.  If you use a shift register, then each iteration of the loop has the value passed in the last iteration of the loop.  I'm not at work, so can't setup a perfect example, but this is from an example I showed someone else.  The first two examples I show here are using shift registers and a 2-D array.  The second example uses an element only available in later versions of LV, but is supposed to be more efficient memory wise.

  • Is there any way to create a circular buffer using the INSERT ARRAY function?

    I saw the example using the REPLACE ARRAY function, but it uses too much CPU power on my laptop. I'm using it for a very sensitive application and saw that the INSERT ARRAY function used much less CPU power.
    I am also not wiring the index on the INSERT ARRAY function so that whatever is read from the buffer is added to the array.
    However, since it is not indexed, I don't know how to set the "write" index back to 0 when it reaches a certain sized array (ie 1000 elements). I was looking for an array property node, but couldn't figure out if one exists for the "current write index".
    Can anyone help?
    Thanks

    I will try to answer this question to my best understanding. I apologize if I interpreted the question wrong.
    You are using the "Insert Array" vi without wiring the index. By doing that, new elements will be added (appended) to the array.
    If you just want to know the current index to stop your acquisition when the array reach certain amount of elements, then you can use the "Array Size" vi to keep track of the size of the growing array. Remember that Array Size = last index + 1 because the index start at zero.
    A second option is that you may want to start over the array when it hits the maximum number of elements that you will allow. If that's the case, then you may want to re-initialize the array to a NULL state by stablishing a condition (for example, when the
    size of the array is 1000, re-initialize). I provided an example attached to this message showing how this can be accomplished. In the example, an 1D array grows in size using the "Insert Array" vi and inserting a random number. When the array reach 4 elements, it is re-initialized. You can expand this example by saving the array first to a file or some other holder before re-initializing the array. The example is in LabVIEW 6.
    Finally, if you want to replace the current values with new values, I think you do not have other choice but to use the "Replace Array" vi.
    Hope this can be of help.
    Regards;
    Enrique Vargas
    www.vartortech.com
    Attachments:
    array_example.vi ‏20 KB

  • Null pointer exception with an array?

    import java.awt.*;
    import javax.swing.*;
    /* Author: Mike Megally
       Problem: Chapter 2, Question 18*/
    class Yearly{
      private double deferred;
      private double taxed;
      private int year;
      public void setdeferred(double amount){
        deferred = amount;
      public void settaxed(double amount){
        taxed = amount;
      public void setyear(int year){
        this.year = year;
      public double getdeferred(){
        return deferred;
      public double gettaxed(){
        return taxed;
      public int getyear(){
        return year;
    class Draw_Grid extends JPanel{
      String colhead[] = {"Name", "Date", "Year"};
      JFrame frame;
      JTable table;
      Draw_Grid(Object data[][]){
        frame = new JFrame("Taxation Without Representation");
        table = new JTable(data,colhead);
        create(data);
      private void create(Object data[][]){
        frame.setSize(500,500);
        frame.getContentPane().add(table);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.show();
    class Calculate{
      private int years;
      private double interest;
      private double amountstart;
      private Object data[][];
      Yearly total[];
      Calculate(int years, double interest, double amountstart) {
        this.years = years;
        this.interest = interest;
        this.amountstart = amountstart;
        data = new Object[years][3];
        total = new Yearly[10];
      public void calc(){
        for (int i = 0; i < years; i++){
          total.setyear(i);
    total[i].settaxed(1);
    total[i].setdeferred(1);
    addtoobject();
    private void addtoobject() {
    for (int i = 0; i < years; i++) {
    data[i][0] = new Integer(total[i].getyear());
    data[i][1] = new Double(total[i].getdeferred());
    data[i][2] = new Double(total[i].gettaxed());
    new Draw_Grid(data);
    public class TaxCheck{
    public static void main(String args[]){
    JFrame frame = new JFrame("test");
    int years;
    double initial;
    double taxrate;
    // gets the command line arguments and converts them
    years = Integer.parseInt(args[0]);
    initial = Double.parseDouble(args[1]);
    taxrate = Double.parseDouble(args[2]);
    //makes the percentage useable
    taxrate = taxrate/100;
    Calculate clc = new Calculate(years, taxrate,initial);
    clc.calc();
    specifically these parts
    public void calc(){
    for (int i = 0; i < years; i++){
    total[i].setyear(i);
    total[i].settaxed(1);
    total[i].setdeferred(1);
    and
    private void addtoobject() {
    for (int i = 0; i < years; i++) {
    data[i][0] = new Integer(total[i].getyear());
    data[i][1] = new Double(total[i].getdeferred());
    data[i][2] = new Double(total[i].gettaxed());
    as far as i know, they should be ok. i really need help on this!

    You haven't initialized your Array elements...
    Example:
    for (int i = 0; i < years; i++){
      total[i] = new Yearly(); // add this
      total.setyear(i);
    total[i].settaxed(1);
    total[i].setdeferred(1)
    When you say "Yearly[] total = new Yearly[10]", you're just creating a holder for 10 Yearly objects. There won't be any Yearlies (haha) until you create them...

Maybe you are looking for

  • How to create a URL in R3 system?

    Hi experts, My requirements is that external application will send a XML message to R3 system via a URL.But I don't know how to create a valid URL in R3 system.Who can help me.many thanks. Kelvin

  • ITunes 11.2.1 is unable to change metadata

    After this recent update of iTunes to version 11.2.1 I'm no longer able to change metadata of any MP3 file without that the spinning ball takes an infinity spinning tour. I have to kill the iTunes process. Befor this update I changed mass of files th

  • Home vs. Work Environment; Can't connect @ Home

    I have a work environment where: Tomcat 5.0.24 running on Win2K Workstation, Computer Name NJEP11 SQL Server 2000 running on Win2K Server, Computer Name DATABASE I have a home environment where Tomcat 5.0.24 (exact copy, file for file) running on Win

  • How to set Panel height to browser height?

    I have a panel in a module in an application (App > Module > Panel). I would like the panel to take up the full height of the browser window. How can I achieve this? Trying to set height="100%" doesn't work, and makes the panel disappear. Setting the

  • JDK on Linux

    Hi Guru's We want to install Solman 4.0 and ECC 6.0 on RHEL5(redhat linux enterprise) and maxdb 7.6 Please suggest us which jdk that we need to go for(Sun or IBM). Please do let us know about the versions like jdk 1.4.2_xx etc. Your help would be mor