| Summary: | ArrayList.size context menu is misleading | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Jonathan Camilleri <camilleri.jon> | ||||
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> | ||||
| Status: | RESOLVED INVALID | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | daniel_megert, eclipse | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 193964 [details]
Screenshot
You're after the "show logical structure" button at the top of the Variables view. Window -> show view -> variables, and depress the button. (It's a little yellow arrow pointing to a blue tree with red boxes off it. I can't find it in the preferences at all.) It, surprisingly, makes Eclipse show the logical structure of the container, what you expect, instead of the actual underlying data. e.g. http://faux.uwcs.co.uk/linkedlistdebug.png The debugger shows the real object. In the case of an array it shows all allocated slots (capacity). Also note that the help/context info is provided by the JRE you are using and not Eclipse. (In reply to comment #3) > The debugger shows the real object. In the case of an array it shows all > allocated slots (capacity). Also note that the help/context info is provided by > the JRE you are using and not Eclipse. Thanks (In reply to comment #2) > You're after the "show logical structure" button at the top of the Variables > view. Window -> show view -> variables, and depress the button. (It's a > little yellow arrow pointing to a blue tree with red boxes off it. I can't > find it in the preferences at all.) It, surprisingly, makes Eclipse show the > logical structure of the container, what you expect, instead of the actual > underlying data. > > e.g. http://faux.uwcs.co.uk/linkedlistdebug.png Thanks (In reply to comment #3) > The debugger shows the real object. In the case of an array it shows all > allocated slots (capacity). Also note that the help/context info is provided by > the JRE you are using and not Eclipse. "There is an important distinction between the capacity of an array list and the size of an array. If you allocate an array with 100 entries, then the array has 100 slots, ready for use. An arraylist with a capacity of 100 elements has the potential of holding 100 elements (and, in fact, more than 100, at the cost of additional reallocations; but at the beginning, even after its initial construction, an arraylist holds no elements at all." Quoted from Core Java Fundamentals Volume 1 (http://www.amazon.com/Core-Java-TM-I-Fundamentals-8th/dp/0132354764). Page 205. |
Build Identifier: M20110210-1200 I'm trying to debug a grammatical issue with the output value of toString(), however, it seems that the output (from Apache log4j) indicates that Player.toString() will return the following value, which is grammatically incorrect, since I want to add a ',' only in between one member and the other, whilst the last member of the ArrayList is still not reached. However, it is noted that while in 'Debug' mode, I cannot directly review the value of the variables 'i'- from the Outline (or other window). It is also noted that the value of size (see eclipse - scr.jpg attached) is misleading considering the the current value of CardsHeld.size() is 2, and, somehow empty place holders are showing up. 117563 [main] DEBUG poker.Poker - Player One holds the following cards: TWO of CLUBS, FOUR of HEARTS, . ... public String toString() { String _cardsHeld = ""; BasicConfigurator.configure(); //TODO: DEBUG grammatical error i.e. comma separating each card and "." for the last card, the last rule is not working as expected. for (int i = 0; i < CardsHeld.size(); i++) { if (i < CardsHeld.size()) {_cardsHeld += CardsHeld.get(i).toString() + ", ";} else if (i == CardsHeld.size()) {_cardsHeld += CardsHeld.get(i).toString() + ".";} } return (name + " holds the following cards: " + _cardsHeld) ; } ... Reproducible: Didn't try