Problems with inserting elements into vectors

Hi,
I have a problem with the setElementAt() method for vectors.
I want to initialise a vector that is same size as a previous vector declared in my program and insert float 0.0 in all the positions.
The code below is a for loop to do just this where count is the size of the previous vector.
for(int i=0;i<count; i++)
               vLargest.setElementAt(zero,i);
          }i have declared zero as a float
float zero = 0.0f;
the error that i'm getting is that it that the vector cannot be applied to a float.
Can anybody tell me what i'm doing wrong?
Thanks

Yes you need to store Objects in your Vector not primitives.
float is not an Object it is a primitive. But Float is an object.

Similar Messages

  • Problem with inserting data into mySQL database with jsp

    I have a jsp page that collects infromation about a users vehicle and puts the data into a mySQL database. Iv'e been messing around with it for ages & i can't seem to get it to work even though i cannot see anything wrong with the code, which can be seen below.
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ include file="Connections/connection.jsp" %>
    <%
    // *** Restrict Access To Page: Grant or deny access to this page
    String MM_authorizedUsers="";
    String MM_authFailedURL="login_form.jsp";
    boolean MM_grantAccess=false;
    if (session.getValue("MM_Username") != null && !session.getValue("MM_Username").equals("")) {
      if (true || (session.getValue("MM_UserAuthorization")=="") ||
              (MM_authorizedUsers.indexOf((String)session.getValue("MM_UserAuthorization")) >=0)) {
        MM_grantAccess = true;
    if (!MM_grantAccess) {
      String MM_qsChar = "?";
      if (MM_authFailedURL.indexOf("?") >= 0) MM_qsChar = "&";
      String MM_referrer = request.getRequestURI();
      if (request.getQueryString() != null) MM_referrer = MM_referrer + "?" + request.getQueryString();
      MM_authFailedURL = MM_authFailedURL + MM_qsChar + "accessdenied=" + java.net.URLEncoder.encode(MM_referrer);
      response.sendRedirect(response.encodeRedirectURL(MM_authFailedURL));
      return;
    String vehicle_details__registration = null;
    if(request.getParameter("txt_registration") != null){ vehicle_details__registration = (String)request.getParameter("txt_registration");}
    String vehicle_details__make = null;
    if(request.getParameter("txt_make") != null){ vehicle_details__make = (String)request.getParameter("txt_make");}
    String vehicle_details__model = null;
    if(request.getParameter("txt_model") != null){ vehicle_details__model = (String)request.getParameter("txt_model");}
    String vehicle_details__colour = null;
    if(request.getParameter("txt_colour") != null){ vehicle_details__colour = (String)request.getParameter("txt_colour");}
    String vehicle_details__tax_class = null;
    if(request.getParameter("select_tax_class") != null){ vehicle_details__tax_class = (String)request.getParameter("select_tax_class");}
    String vehicle_details__chasis_num = null;
    if(request.getParameter("chasis_num") != null){ vehicle_details__chasis_num = (String)request.getParameter("chasis_num");}
    String vehicle_details__status = null;
    if(request.getParameter("radio_status") != null){ vehicle_details__status = (String)request.getParameter("radio_status");}
    String owner_details__MMColParam = "1";
    if (session.getValue("MM_Username") !=null) {owner_details__MMColParam = (String)session.getValue("MM_Username");}
    Driver Drivervehicle_details = (Driver)Class.forName(MM_connection_DRIVER).newInstance();
    Connection Connvehicle_details = DriverManager.getConnection(MM_connection_STRING,MM_connection_USERNAME,MM_connection_PASSWORD);
    PreparedStatement vehicle_details = Connvehicle_details.prepareStatement("INSERT INTO vehicle_man_db.vehicle_details (registartion, make, model, colour, tax_class, chasis_num) VALUES ('"+ String vehicle_details__registration + "', '"+ String vehicle_details__make + "', '"+ String vehicle_details__model + "', '"+ String vehicle_details__colour + "', '"+ String vehicle_details__tax_class + "', '"+ String vehicle_details__chasis_num + "', '"+ String vehicle_details__status + "')");
    vehicle_details.executeUpdate();
    %>
    <form name="add_vehicle_form" id="add_vehicle_form">
      <p>Registration mark:
        <input name="txt_registration" type="text" id="txt_registration">
    </p>
      <p>Make:
        <input name="txt_make" type="text" id="txt_make">
    </p>
      <p>Model:
        <input name="txt_model" type="text" id="txt_model">
    </p>
      <p>Colour:
        <input name="txt_colour" type="text" id="txt_colour">
      </p>
      <p>Tax Class:
        <select name="select_tax_class" id="select_tax_class">
          <option value="AAA">Band AAA (up to 100g/km)</option>
          <option value="AA">Band AA (101 - 120g/km)</option>
          <option value="A">Band A (121 - 150g/km)</option>
          <option value="B">Band B (151 - 165g/km)</option>
          <option value="C">Band C (166 - 185g/km)</option>
          <option value="D">Band D (Over 185g/km)</option>
        </select>
      </p>
      <p>Chasis Number:
        <input name="txt_chassis_num" type="text" id="txt_chassis_num">
    </p>
      <p>Status: active:
        <input name="radio_status" type="radio" value="1" checked>
        off-road
        <input name="radio_status" type="radio" value="0">
      </p>
      <p>
        <input type="submit" name="Submit" value="Submit">
    </p>
    </form>
    <%
    Connvehicle_details.close();
    %>This is the error I am getting from the server
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 3 in the jsp file: /add_vehicle_form.jsp
    Generated servlet error:
    C:\Servers\Tomcat 5.0\work\Catalina\localhost\Assignment\org\apache\jsp\add_005fvehicle_005fform_jsp.java:113: ')' expected
    PreparedStatement vehicle_details = Connvehicle_details.prepareStatement("INSERT INTO vehicle_man_db.vehicle_details (registartion, make, model, colour, tax_class, chasis_num) VALUES ('"+ String vehicle_details__registration + "', '"+ String vehicle_details__make + "', '"+ String vehicle_details__model + "', '"+ String vehicle_details__colour + "', '"+ String vehicle_details__tax_class + "', '"+ String vehicle_details__chasis_num + "', '"+ String vehicle_details__status + "')");
    ^
    1 error
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Any help would be much appreciated.
    Thanks

    use this ...
    PreparedStatement vehicle_details =
    Connvehicle_details.prepareStatement("INSERT INTO
    vehicle_man_db.vehicle_details (registartion, make,
    model, colour, tax_class, chasis_num) VALUES
    vehicle_details .setString(1,String
    vehicle_details__registration );
    vehicle_details setString(2,String
    vehicle_details__make );
    vehicle_details .setString(3,String
    vehicle_details__model );
    vehicle_details .setString(4,vehicle_details__colour
    vehicle_details .setString(5,String
    vehicle_details__tax_class);
    vehicle_details .setString(6,String
    vehicle_details__chasis_num );
    vehicle_details .executeQuery();Even you need a screwing up... what's the point putting that String inside. That's the bloody error.

  • Need help with inserting element into a grid

    Hi,
    I'm trying to add an element in a 11x11 grid, but the program stop and give me 2 error (identified in the code) and I have no idea on what is wrong with those line. If anyone have any idea, suggestion or an other way to do this, I could use some help.
    Thx
              for (int i = 0; i != NUMBER; ++i) {
                      int row = 2 + (int)(Math.random() * 10);
                   int col = 2 + (int)(Math.random() * 10);
                   int nb = 0 + (int)(Math.random() * 2);
                   boolean horizontal = true;
                   if (nb == 1)
                        horizontal = false;
                   if (horizontal) {
                        if (row <= element.getDimension()) {  // error at this line
                             for (int j = 0; j != element[i].getDimension(); j++) {
                                  grid[row + j][col]     = "X";
                        else {
                             for (int j = 0; j != element[i].getDimension(); j++) {
                                  grid[row - j][col]     = "X";
                   if (! horizontal) {
                        if (col <= element[i].getDimension()) { // error at this line
                             for (int j = 0; j != element[i].getDimension(); j++) {
                                  grid[row][col + j]     = "X";
                        else {
                             for (int j = 0; j != element[i].getDimension(); j++) {
                                  grid[row][col - j]     = "X";

    My error is : Exception in thread "main" java.lang.NullPointerException
    at Grid.<init><Grid.java:67>
    at PrincTp1.main<PrincTp1.java:24>
    That's my class element
    public class Element {
    // Attributs
         private int dimension;
         private boolean horizontal;
         private String name;
         private int row;
         private int col;
    // Constructor
         public Element(int dimension_, String name_) {
              dimension = dimension_;
              name = name_;
         public Element() {
    // getter/setter
         public void setDimension(int dimension_) {
              dimension = dimension_;
         public int getDimension() {
              return dimension;
         public void setHorizontal(boolean horizontal_) {
              horizontal = horizontal_;
         public boolean getHorizontal() {
              return horizontal;
         public void setNom(String name_) {
              name = name_;
         public String getName() {
              return name;
         public void setLigne(int row_) {
              row = row_;
         public int getRow() {
              return row;
         public void setCol(int col_) {
              col = col_;
         public int getCol() {
              return col;
         }

  • Problem with align element.

    Hi everybody,
    i have a problem with align element on my page. I explain:
    i have used into a panel page a panel group to align my element horizontal, but when i set the vertical-align on top, the element are align in middle.
    Now is......
    text text text text text text
    text text text text text text
    text text text text text text
    text text text text text text tablelayout
    text text text text text text
    text text text text text text
    text text text text text text
    But i wont........
    text text text text text text tablelayout
    text text text text text text
    text text text text text text
    text text text text text text
    text text text text text text
    text text text text text text
    text text text text text text
    Thanks.

    Have you tried using a panelHorizontal instead of a panelGroup?
    The components are automatically laid out horizontally and it has a Valign property that you can set to top.

  • Problems with INSERT  syntax ?

    Dear programmers,
    I am have a problem with INSERT Syntax,
    I have a table with 11 fields out of which one is auto_increment field(id), Now my problem is, Do i need to specifiy autoincrement field in INSERT statement. I dont thinks ?
    My Insert statement is as follows ,
    int result = st.executeUpdate("insert into tablename"
              +"(name, user_group, lage, preis, anmerkung, exp_uri, timestamp, nummer)"
              +"values +Objekt+"','"+Kategoriekey+"','"+Lage+"','"+Preis+"','"+Anmerkung+"','"+Dateiname+"','"+date.getTime()+"','"+ObjektID+"')");
    thanks in advance
    bye

    The answer to your question is maybe. Each database handles autoincrements differently. What database are you using?
    I also noticed that you are doing an insert using the standard Statement. You should look into using PreparedStatements for performance reasons and issues such as single quotes from within a string.
    Matt

  • How to insert elements into an array after each iteration of a for loop

    I am new to labview and working on an application where I am supposed to store an element into an array (without overwriting) after each iteration in a for loop. I have tried using Build Array Function keeping the indicator outside the for loop and played with indexing but didn't work. Please suggest me an idea how to do it.
    Thanks
    Solved!
    Go to Solution.

    Thank you for your suggestion.Here is my actual application attached . In the first image, a difference in time is evaluated and an enum const of insert into array is passed to the shift register where it takes to Insert element into array phase (Second image). I need to enter the time difference into an array after every loop iteration. Please have a look and could you let me know where I am mislead.
    Attachments:
    Image 1.JPG ‏88 KB
    Image 2.JPG ‏71 KB

  • Problem with installing Elements - from noob

    I have problems with installing Elements, it gives my an unknown mistake - I already have CS4 up and running, could this be the case?

    Chances are not very good that pse 4 will run on os x 10 6.8 unless you were upgrading from an earlier mac version that already had pse 4 installed.
    as per this:
    http://forums.adobe.com/message/4474236#4474236

  • Problem with Photoshop Elements Printing

    I have been using Photoshop Elements for a couple of years now and know it pretty well.  Today while attempting to print, a strange problem came up:  After going through the protocol to make a print, just before the image prints PE does a very fast auto correction that basically ruins all the color correction I have made on the image.  How do I disable this function?

    Hi and thanks for your reply. I checked the settings under "Print", "More Options", then "Color Management" and it only has "Print Space", none of the three options that you said I should have.  Am I looking in the wrong place?
    Date: Mon, 3 Sep 2012 11:14:57 -0600
    From: [email protected]
    To: [email protected]
    Subject: Problem with Photoshop Elements Printing
        Re: Problem with Photoshop Elements Printing
        created by 99jon in Photoshop Elements - View the full discussion
      Check your color management by clicking More Options in the print dialog There are basically three options:1) Printer Manages Color2) Elements Manages color3) No color Management Make sure everything is consistent e.g. if you choose Elements manages color make sure color management is switched off in the print driver. 
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4669848#4669848
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4669848#4669848. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Photoshop Elements by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Y have problems with Photoshop Elements 12  Bug after reinstallation complet  Impossible working ??

    Morning !
    We have many problems with PHOTOSHOP ELEMENTS 12 ?
    After installation on MAC OS X   YOSEMITE  .
    S O S !!

    Exporter vers photoshop do you receive any specific error messages?  In what way is Photoshop Elements 12 not working?

  • Problems with Photoshop Elements 11

    I have a problem with Photoshop Elements 11, which i bought last week. Installing was completed according the instructions. When I started to use the program my one year old HP-computer with Windows 8.1 informed that there a failure in the Photoshop program and the did not open.

    attach a screenshot of the error message.

  • Problem with premiere elements 4.0

    i am having
    problem
    with premiere elements 4.0. it keeps on crashing and when i put pictures on the timeline it comes up black. when i try to preview it either it shows black or sometimes the picture but i cant see it to delete if i wanted to. also it gave me a message something like that adbe is running low on memory and i should be caution

    This is aimed at Premiere Pro, but may help
    Work through all of the steps (ideas) listed at http://ppro.wikia.com/wiki/Troubleshooting
    If your problem isn't fixed after you follow all of the steps, report back with ALL OF THE DETAILS asked for in the FINALLY section, the questions at the end of the troubleshooting link... most especially the codec used... see Question 1

  • JDeveloper Extension Problem with Navigator Elements

    Hi,
    I have a problem with the elements of the JDev Navigator.
    At IDE startup I want to set an overlay for the elements on the active project.
    This function is implemented in the Subversion Extension too.
    How can I access the elements of an active project in the navigator?
    It is not a problem to set an overlay with the ContextMenuListener.
    Thank you for your help.
    Greetings,
    Benjamin Oelenberg

    Please take a look at the Extension SDK sample projects. There is a sample that does exactly this.
    Install the Extension SDK from the Help --> Check for Updates dialog and after restart, say yes to installing the sample projects.

  • I recently upgraded our iMac to Yosemite OS and now have a problem with Photoshop Elements 11:  the move tool selects an image or text layer, but then I try to drag the selection somewhere else on the page and it snaps back to the original location, howev

    I recently upgraded our iMac to Yosemite OS and now have a problem with Photoshop Elements 11:  the move tool selects an image or text layer, but then I try to drag the selection somewhere else on the page and it snaps back to the original location, however the arrows will move it OK.  Also I cannot drag the selection to another photo in the photo bin as before.

    Hi,
    Please refer: http://helpx.adobe.com/photoshop-elements/kb/pse-stops-responding-yosemite.html
    Thanks,
    Anwesha

  • Problems with ps elements 10 on imac

    hi,
    i just downloaded the programm yesterday from the app store onto my imac. i want to use it as an extention to my aperture 3.
    I have the following questions/problems:
    + starting the programm takes at least 2 minutes, is this normal? I use an Imac Quadcore I7 with 12 gb onboard
    + the preferences: i can only extend the used memory up to 3gb, although i have 12 gb on board?
    + I can not store the preferences, when I shut the programm down, it tells me I do not have the legitimation to store the preferences?!
    + panorama foto work is mostly running out of memory?! 12gb on board
    Please can anybody help me?
    Thanks
    mikle

    No, it does not work on the other account. Problem is still/again the same. In the new account it works perfekt.
    Von meinem iPad gesendet
    Am 08.01.2012 um 22:16 schrieb "Barbara B." <[email protected]>:
    Re: problems with ps elements 10 on imac
    created by Barbara B. in Photoshop Elements - View the full discussion
    If it works in the new account it should hopefully work in your other account, so just log out of that one and go back to the old one and see if it does.
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4125222#4125222
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4125222#4125222. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Photoshop Elements by email or at Adobe Forums
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Problems with importing images into Lightroom cc

    Problems with importing images into Lightroom cc
    I have installed lightroom cc and having trouble imortera images from my Canon 1DX.
    Lightroom starting the capture, but then nothing happens more, if I turn off the camera, I get error message photo 100-200 could not be loaded.
    Now I have left lightroom 5 and where the input port works fine.
    What happened to the upgrade from Lightroom 5 to lightroom cc?
    The camera has the latest software.

    I've now tested in various ways.
    First, I have images on both memory cards in the camera.
    Test1) Selects Not all of the photos in the camera at the input port bearings, it seems to work fine.
    Test 2) selects all cards in the camera and then get the following, Lightroom starts inportera short but stops and nothing happens (Fig.1).
    I turn the camera off after a while and get the next meddelnade (picture 1)
    Which can be translated:
    "The following files were not imported because they could not read (351)
    Property 1-100
    etc. "
    Picture 1.
    Picture 2

Maybe you are looking for