NullPointerException error with class composition

0

I have a class named Users, which has a Sensors-like vector as an attribute

protected Sensors sensors[10];

It also has the setDescription method

public void setDescription (int ind, String description)
{
    this.sensors[ind].description = description;
}

After instantiating an object called user, I tried to call by the method like this:

user.setDescription (ctr, description);

But it's giving NullPointerException. If anyone can help me, I'm grateful.

    
asked by anonymous 11.07.2015 / 01:45

1 answer

2

This happened because the protected Sensors sensors[10] attribute was not initialized.

You can do this, either in the constructor or in the attribute declaration itself, like this: protected Sensors[] sensors = new Sensors[10];

    
11.07.2015 / 05:33
How to use two OpenGL viewports using QT? ______ qstntxt ___

I searched the net but found nothing to upload a file and converted it to %code% and then search the text inside it for results.

/ p>

Someone knows how this is done so I can leave some links for me to study the case.

    
______ azszpr73152 ___

Converting binary files to %code% will not make a search work, each file has its own format.

For each file type you will have to use a method to extract the data and save it in a %code% , some example:

  • XML use link

    Example:

    %pre%
  • CSV use link

    %pre%
  • XLS will probably have to use a library to facilitate such as link or link

  • These are just a few examples, for each format you implement in your application you will have to use a new script.

    I believe that there is no "magic" solution ready for this, you will have to take what exists and create an application based on it.

    To make the query, let's suppose that you saved all %code% to a folder, so you should do a search similar to this:

    %pre%     
    ______ azszpr73192 ___

    I do not know if I understand your question right, but if you want the list of files listed in a txt file, use the following command:

    %pre%

    I hope I have helped.

    Embrace

        
    ___