Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel
Accepted Solution

Problem creating Array of objects

Hi,

 

I have a xml.

I am reading elements from it using for loop.

I want to store String data in an array whose size is not fixed.

I am currently using Vectors for this. But while storing the first Sting

some sort of error occurs and no exception is catched.

 

Code:

Vector title;

 

for (int s = 0; s < loop; s++) {

            Node fstNode = nodeLst1.item(s);
            
            if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
          
                   Element fstElmnt = (Element) fstNode;
              NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("title");
              Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
              NodeList fstNm = fstNmElmnt.getChildNodes();
              System.out.println("First Name : "  + ((Node) fstNm.item(0)).getNodeValue());
              
             title.insertElementAt((((Node) fstNm.item(0)).getNodeValue()),s); //ERROR OCCURS HERE


              }
             
            }
        }

 

Any help??

 

Thanks

Abhinav

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Highlighted
Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: Problem creating Array of objects

you are declare the Object but not creating the instance of it.

 

Use this

Vector title = new Vector();

I think will be solved.

------------------------------------------------------------------------------------
Press Kudo to say thank to developer.
Also Press the Accept as solution Button when u got the Solution.

Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel

Re: Problem creating Array of objects

Thanks Nitin

 

I just missed that Smiley Very Happy

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot