• Post Reply Bookmark Topic Watch Topic
  • New Topic

Add(index i, Object o) method of arraylist showing random behaviour  RSS feed

 
vikas bisla
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dmAcc12.dmTree[0].clsAppAddr.lstPort.add(0,portNode); it is adding at 11 position in the arraylist and first 10 entries in the arraylist are null. It shows first index = 11 , lastIndex = 12 and first 10 postion are null.

vikas bisla
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for letting us know.

Or...did you have an actual question?
 
vikas bisla
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should add at 0th position .why it is adding at 11th postion.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's "firstIndex" and "lastIndex"?
 
vikas bisla
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while deuging in ecllipse it was showing first index = 11 and last index = 12 but actually adding at 0th position. thanks for your reply.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the declaration and construction of the member.

(Is all of the code a trainwreck of leaking internal details like the line you posted?!)
 
vikas bisla
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dmAcc12.dmTree[0].clsAppAddr.lstPort.add(portNode); Adding at 0th position in this case first index = 0 and last index = 1 but

dmAcc12.dmTree[0].clsAppAddr.lstPort.add(0,portNode); Adding at 11th position in this case first index = 11 and last index = 12
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Post the declaration and construction of the member.
 
vikas bisla
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class DmAcc12SubTree
{



public App_DMAcc12_AppAddr_T clsAppAddr = new App_DMAcc12_AppAddr_T();
public App_DMAcc12_AppAuth_T clsAppAuth = new App_DMAcc12_AppAuth_T();



public class AppNode
{
public char cFormat;
public long lSize;
public String straucData;
};





public class App_DMAcc12_Port_T
{
public char cPort_modified[] = new char[DmAcc12Constants.APP_DMACC_MAX_PORT] ; //'T'/'F'->InTact/Ruptured
public ArrayList<AppNode> lstPortId = new ArrayList<AppNode>();
public ArrayList<AppNode> lstPortNbr = new ArrayList<AppNode>();
} ;




}


DmAcc12SubTree.AppNode appNode = null;
DmAcc12SubTree.App_DMAcc12_Port_T portNode = null;

portNode = dmAcc12.dmTree[0].new App_DMAcc12_Port_T() ;

appNode = dmAcc12.dmTree[0].new AppNode();
appNode.cFormat = 147;
appNode.straucData = "TestData";
appNode.lSize = "TestData".length();

portNode.lstPortId.add(0,appNode);
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, that's... hard to read.

If it's a straight JSE ArrayList I have no idea why it would be getting screwed up internally unless there's more to it than what we see here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!