Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Errored Code

Options
  • 18-02-2004 10:56am
    #1
    Closed Accounts Posts: 537 ✭✭✭


    public void GetSample(int size,int MAX)
    {

    int bins []= new int [size];
    int Data []= new int[MAX];
    String sql = "SELECT DISTINCT Count(Accepts.Queue)FROM Accepts WHERE Accepts.Queue='jComboBox3' And (Accepts.TimeOfAccept Between #JComboBox2# And #JComboBox1#);";
    ResultSet result = stmt.executeQuery(sql);

    for (int k = size; k<0; k--)
    {
    for (int i = 0; i<result+1; i++)
    {
    (result % [k] = int bin );
    }
    }
    }



    Can anyone tell me why this wont work


Comments

  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Maybe if you explained how it isn't working nd what its supposed to do when it does work????

    jc


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    I'm guessing it's something to do with this line:
    (result % [k] = int bin [i]);
    

    Doesn't look like a valid statement to me all. Try not to do too much on one line, break the action up into it's smallest parts and do them one by one. It should make your code more readable too.


  • Closed Accounts Posts: 537 ✭✭✭JohnnyBravo


    It counts the number of cases from a table based on Jcombobox 3 (list of cases) between a start and an end date the other two combo boxes

    it then % the result by 24 23 22 21 etc all the way down to 1 to give you 24 numbers and places them in the array bin

    The problem is (res% [k] = int bin );

    Main.java [327:1] illegal start of expression
    Main.java [327:1] not a statement


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by JohnnyBravo
    and places them in the array bin

    The problem is (result % [k] = int bin );


    Well, thats not placing anything in the bin. An assignment (=) reads from the Right Hand Side (RHS) and assigns to the Left Hand Side (LHS)

    So, your statement is reading from the bin (although the RHS isn't valid syntax anyway) and attempting to write the result into res%[k] which is clearly also invalid.

    So, the first thing is to reverse the statement :

    bin = (int) (result % [k])

    I've left the int on teh RHS because I assume you want to cast the result to an int before assigning it to the bin array.

    But, this won't work either, I'm pretty sure.

    Firstly, you can't use a ResultSet object (your 'result' variable) in a calculation. You need to go read up how to retrieve a value from that into something else like an int, float, or whatever.

    So, figure that out, and lets assume you write the vbalue into something which we will call result_value.

    Then your resulting statement, I think, should look something like :

    bin = (int) (result_value % k)

    Yes?

    jc


  • Closed Accounts Posts: 537 ✭✭✭JohnnyBravo


    yup done and done cheers one function down


  • Advertisement
Advertisement