• Post Reply Bookmark Topic Watch Topic
  • New Topic

While problem with assignement on String array  RSS feed

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a while that run correctly,
when i insert an assignment in it, it stop to work, and give me just the first iteration, stopping on the assignement
no error displayed, just the while stop



the class where i call method for get and set array
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What assignment? I can't see any assignments in that while loop.
What is the size returned from your model?
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:What assignment? I can't see any assignments in that while loop.
What is the size returned from your model?


i assign a value with a method setIngredient(string,int)

what you mean with the size of model? oh just got it:P ( edit ) i try with many size, i have a list with the add and remove button, so sometimes i add 3 elements, sometimes 4 and so on
 
Ranch Hand
Posts: 147
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Antony Amicone wrote:what you mean with the size of model?


He wants to know what jList1.getModel().getSize() returns. I assume it's greater than one?
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i put 4 element in my array i have a stamp like that

0<4
water 1oz 2lt

cause it stop at first iteration, if i remove that assignment, i have all the while with correct stamp
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After the c++; call and before the end of the loop, add some debugging lines, to print out the value of c and the present size (as previously mentioned).
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i added 4 ingredients, and pressed the button

test Insert here your recipe null 5 4 15
0<4
aaaaa 1.1oz 33.0gr

this is the result, if i remove the assignment the while print everything...... but i think the while is corrected
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Antony Amicone wrote:i added 4 ingredients, and pressed the button

test Insert here your recipe null 5 4 15
0<4
aaaaa 1.1oz 33.0gr

this is the result, if i remove the assignment the while print everything...... but i think the while is corrected


i'm trying many test, but he just stop at the method for the assignment, did i make scope error or something like that? i dont think so
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said before, add some debugging after c++; and before the end of the loop. There is no obvious reason in what you posted for your loop stopping. You need to work out for yourself what is going on.
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:As I said before, add some debugging after c++; and before the end of the loop. There is no obvious reason in what you posted for your loop stopping. You need to work out for yourself what is going on.


done and i posted the result


same result, it doesnt arrive after c++ it stops setIngredient
 
Jan Hoppmann
Ranch Hand
Posts: 147
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try debugging if you have a tool that supports it (e. g. Eclipse), so you can better understand what happens.
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan Hoppmann wrote:Try debugging if you have a tool that supports it (e. g. Eclipse), so you can better understand what happens.

i use netbeans, it can debug but never done, what should i do?
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Double-click the left of the line with c++; in.
  • You will get a breakpoint, which is a little red blob next to the line number.
  • Execute your application in debug mode.
  • It will stop when it reaches the breakpoint.
  • you should be able to inspect the state of all objects, so you can find whether there has been any change in the size field in your List.
  • You can also see the local variables, so you can see the value of c.
  • You can use step into to go into a method call (probably what you want at present).
  • You can use step across to call a method without inspecting the details of what is happening.
  • You can use step return to complete the method you are running at the moment.
  • You may be able to use f6 f7 and f8 for these step instructions.


  • You want to see whether the value of size and the value of c are what you expect. Step across might be called step over or similar.

    They use a very very different system for debugging on Eclipse . . .





    . . . Eclipse breakpoints are blue
     
    Antony Amicone
    Ranch Hand
    Posts: 125
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    this is result for debugging

    test11111111 Insert here your recipe null 5 4 15
    0<2
    555 0.1oz 5.2gr

     
    Campbell Ritchie
    Marshal
    Posts: 56600
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    That doesn't show the size, nor does it show the value of c at the end of the loop.

    And why are you allowing null values?
     
    Antony Amicone
    Ranch Hand
    Posts: 125
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Campbell Ritchie wrote:That doesn't show the size, nor does it show the value of c at the end of the loop.

    And why are you allowing null values?

    so where i have to see size and c value?

    the value null is ok in that field
     
    Antony Amicone
    Ranch Hand
    Posts: 125
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    it says in the output

    LineBreakpoint NewJDialog.java : 184 successfully submitted.

    i have a thing bout String out of bound -5 in another window, but there is written issue submitted, i never submitted
     
    Antony Amicone
    Ranch Hand
    Posts: 125
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Antony Amicone wrote:it says in the output

    LineBreakpoint NewJDialog.java : 184 successfully submitted.

    i have a thing bout String out of bound -5 in another window, but there is written issue submitted, i never submitted


    could be cause i dont set any size to the array in the class? but i tryed to correct putting the private ingredients as = new ingredients[20];
     
    Campbell Ritchie
    Marshal
    Posts: 56600
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Don't know. I cannot see any reason in what you have posted why your loop could terminate after 1 iteration, unless the size is 1. You say it is 4, so maybe the size has changed.
    I can't remember how to run an application on NetBeans in debug mode, but that is what you have to do, then you need to find how to inspect all your objects. You look for the jList1 object.

    You never said the code was inside a try. Read this and this. What are you putting in your catch? If you have an empty catch, that would be very dangerous, ( ) because you would simply obscure an Exception and not know it is happening. If you are suffering an OutOfBoundsException, you need to know why.
     
    Antony Amicone
    Ranch Hand
    Posts: 125
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    now works ;) ty to all
     
    Don't get me started about those stupid light bulbs.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!