How do I modify an Array into a collection

Hi I'm havin a real hard time modifying an Array into a collection, heres the code I'm working with
I have to modify all the Arrays of this code....
public class Student {
     private String           name;
     private float []      grades;
     private int           finalGrade;
     public Student(String name) {
          this.name      = name;
          this.grades = new float[5];
          for (int i = 0; i < grades.length; i ++) {
               grades[i] = 0.0f;
          finalGrade = 0;
     public String toString() {
          String studentInfo = " Grades for " + name + ": ";
     for (int i = 0; i < grades.length; i ++)
     studentInfo += " " + grades;
     studentInfo += "\n final grade: " + getFinalGrade();
     return studentInfo;
     private void setFinalGrade() {
          float temp = 0.0f;
          for(int i = 0; i < grades.length; i++)
               temp += grades[i];
          finalGrade = Math.round(temp/grades.length);
     public int getFinalGrade() {
          this.setFinalGrade();
          return finalGrade;
     public void setGrade( int index, float grade) {
          this.grades[index] = grade;
     public float[] getGrades() {
          return grades;
     public String getName() {
          return name;

I'm kind of new at this I just started to learn about
that, is there an example u could give me to inspire
me ?
Object[] o = new String[]{"one", "two", "five"};
Collection ascollection = Arrays.asList(o);
//the returned Collection (List) is unmodifiable,
//so if we want to remove or add items, we need
//a copy:
Collection copy = new ArrayList(ascollection);
copy.remove("two");
String[] backagain = (String[]) copy.toArray(new String[copy.size()]);

Similar Messages

  • How to enter two different arrays into two columns of a multi column listbox

    Hi All,
    I have two different arrays of values suppose 1 array A(1,2,3,4,5) and another array B(3,4,5,6,7). I want to write these to arrays into a multicolumn listbox such that 1st column would be array A and 2nd column would be array B.
    Thnx in advance
    Solved!
    Go to Solution.

    I still couldnt understand how to do it...
    I am posting here my VI. here the 1, 2, 3, 4 are some controls. If i enter any value, the calculated Voltage and current are continously pushed in the array. Now i have display these arrays in the multi column listbox as 1st column be the voltage and second column being the current.
    Attachments:
    manual_graph.vi ‏643 KB

  • How to bring data from arrays into xy-graph?

    Hello,
    i have some data which is currently stored in two arrays. One array with values and another array with timestamps.
    Now my questions is how can i bring/convert these into the format of XY-graph?
    Thanks for help.

    Hi One,
    - Why do you use a InsertIntoArray when you want to append new plots to an array of plots? Use BuildArray!
    - Why do you initialize your shift register to already contain (atleast) one plot?
    - Why do you use a shift register at all? Why not rely on the autoindexing output tunnel? 3 iterations will yield 3 plots easily…
    - Why don't you clean up your VI before uploading?
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How do I combine two arrays into one?

    I am trying to combine two byte arrays into one. What function do I use that will put in the information in the same order just combined?

    battler. wrote:
    Julien,
    Used LV for years.  Never knew that (concatenate inputs).  Wouldn't believe the lengths ive used to get around it.  Thanks
    Same here! I actually learned about it taking a sample test for the CLAD.
    Richard

  • How To Read/Modify/Write Array?

    Ive got a bunch of switches, where each switch represents a bit in a
    word...
    So from each switch, in the control panel, it goes throu a boolean to
    integer vi, and then to a x*2^n vi.
    I then set a constant for each n.. so that if the switch is true (x=1
    after the conversion) and n = 5 for that switch,
    then the output will be 1 * 2^5.
    Finally, I add all 16 outputs together (x*2^0 to x*2^15) to create a
    word.. I actually have so many switches
    that I have a couple of words (each made up with the above scheme)!
    So far, this works fine, however, my question is, I would like to have
    a global array that contains these words. I
    dont want to insert this word into the array, but rather, I'd like to
    sort of latch the values...
    If in the array's word, the n bit was already one (i.e. that switch at
    one point was on), then I dont want to reset it
    to 0, even though the switch is off now.
    This probably sounds confusing, I know I am confused just reading that
    back, anyhoot, if I could make a global
    array (ten 16-bit unsigned words), that I can read any word from,
    modify it and set it back to its same place,
    that would be great!

    Hi Anonoymous
    Here's one quick example that does what you want, it functions like a function global and relies on boolean logic.
    For your own experience I challenge you how to reset just one bit or word.
    Also you have to connect the connector pane.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    quickbitregister.vi ‏20 KB

  • How to input 1d waveform array into lock in amplifier

    I have a LabView application that I need to modify to include a lock in amplifier.  The application uses a DAQ card to repeatedly capture a 0.1s sample of two signals (one signal, one reference) during a laboratory test.  Previously the measurement was being made by the basic RMS module to record the VRMS of the signal, and the reference ignored.  However, the measurements I am now performing are at a much lower S:N and so I'd like to use a simple LIA from the NI kit. 
    I am happy (I think) with the setup of the LIA but I'm struggling to understand the input data requirement.  It has to be a 2D array, with the reference signal identifited.  However, the output from the part of the utility that captures the waveform is a 1D array of waveform.  Could someone advise me on how to convert from the 1D array of waveform to a 2D array suitable for input to the LIA?
    As you might have guessed I'm a newbie to LabView, I'm trying to modify an application designed and assembled by a former colleague, so I'd appreciate simple suggestions! 
    TIA.
    Solved!
    Go to Solution.

    I tried that but fell at the first hurdle.  I've attached the error message that I got.  It refers to the issue being due to connecting the type Waveform (DBL) to a 1D array of double.  Apologies if I'm missing something simple here, software is not my strong point.
    I'm a bit confused as to why the LIA (or its subVI's) require a 2D array.  I would have thought, from experience with hardware LIA (5210's etc) that the VI's would want a waveform to process.
    Each entry in the TDMS file is a 0.1s capture of an ~800Hz sine wave, along with the reference signal from the chopper that generated the modulation.  I'm a bit confused as to how this data gets represented in a 2D array for the LIA.  I assume that the waveform is broken into an array of amplitude versus time for each sample and that each sample is then indexed in the 2D array?
    Anyway, all help greatly appreciated.
    Thanks.
    Message Edited by Ringding on 03-27-2009 12:25 PM
    Attachments:
    connection error.jpg ‏84 KB

  • How to import modified files back into Muse

    Maybe this is an easy sync issue....hopefully.
    I've exported my html files from Muse (after publishing to Biz Catalyst) and want to modify the html, such as ad href's to divs in the slideshow, etc. How can I import these modified html files back into Muse so I can publish back to Business Catalyst?
    I realize it's an easy solution to host the exported files on another server, but I'd really like to stay within the Muse/Biz Catalyst environment with updated html's.
    thanks much!!

    There isn't a way at this time to import HTML files into Muse and expect it to load in Design mode for a subsequent re-publish. The only kind of editing that Muse supports today (outside of Muse) is through Business Catalyst's In-Browser editing feature but that is limited to editing only text (without any formatting or styles) and foreground images <http://www.adobekb.com/working-with-in-browser-editing_pt01.html>. Feel free to submit your feature request over at our Ideas section.
    Thanks,
    Vinayak

  • How can I convert an array into a .wav file?

    I have an array of points that I need converted and written into a .wav file. Any help?

    Indeed there is!
    Look at the attached vi....that's about all there is to it!
    Good Luck..
    Eric
    Eric P. Nichols
    P.O. Box 56235
    North Pole, AK 99705
    Attachments:
    ARRAY_TO_WAVE.vi ‏17 KB

  • How to insert a 2D array into the end of X axis of the initial array?

    Hi, friends, I have a question and look for an advice. I have several input data, each of which has 4 rows and unknow columns. Each time I receive the input, I need to combine it to all of the previous ones by adding it to the end of X axis of the previous combined data. I must do it because, later, I need to run my model and my model read input for each column of 4 rows. How should I do it? Also, should I initiate an array before reading all of the inputs? The inputs are F32 format. Thank you very much for any of your advice.

    Building a 2D array row-by-row is easy. You either use "build array" if you need to update the indicator during the run, or you simply autoindex at the loop  boundary (FOR or WHILE).
    Two possibilities are shown in the attached image. If your arrays are getting large and you use a while loop, there are possibilities that are more memory efficient. You would initialize a 2D array (e.g. filled with NaNs) of an upper boundary of the final expected size, then replace rows as you go.
    (Notice that if you use autoindexing on a FOR loop, the final size is known from the beginning so memory can be allocated efficiently)
    Message Edited by altenbach on 11-01-2006 09:19 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    AppendRows.png ‏5 KB

  • How to include elementry search help into predefined collective search help

    Hi guys...
         how to include the user defined elementry search help into pre-defined collective search help.. pls reply as soon as possible..its urgent..
    regards
    kirankpasupuleti

    Hi Kiran,
    I have a complete doc on this which gives you step by step procedure to achieve the same.
    If you want I can send you the docs.
    Please give me your email id.
    Regards,
    Amit Mishra

  • How do I put raw images into smart collections?

    I have just created some smart collections, however the CR files were rejected.  Is there a way to include them?  I shoot raw/jpeg, so would like both formats in the collection.
    Thanks.

    I just checked Raw images in smart collections. It just worked like any other JPEG files.If u can view thumbnails of Raw in bridge,as per my assumption,there cannot be any problem in creating smart collection.If u can not view thumbnails u may need to update the bridge to read the particular camera model image.any contradiction will be received in right spirit

  • How do I convert an array of BYTES (where each BYTE represents a bit) into a single Hex number?

    I am reading a signal from a USB-8451. This signal is stored as an array where each element represents a bit in the signal, but is stored in the array as a byte. How do I convert this array into a single Hex number. I attatched what I have so far, there are a few extra things to help me see what ia going on. One code uses Queue and the other uses arrays, let me know if you can help.
    Attachments:
    845x_EEPROMarrays.vi ‏27 KB
    845x_EEPROM.vi ‏26 KB

    mkssnwbrd wrote:
    ... so we can't introduce any other forms of signals or power into the circuit other than what the circuit already has. Trithfully I don't really know how I2C devices work, but my mentor here says that we can't use an I2C method becuase it will introduce voltage into the circuit and may damage out TCON chip.
    That makes absolutely no sense. What do you think is happening when you write the digital lines? You're setting a pin high. That voltage is being generated by the 8451x. I think you're not understanding what your mentor is saying. If it's an I2C device then you should be able to use the I2C function to simply talk to it. You still have not indicated what the device is, so there's little more I can say about that aspect of it.
    As far as the conversion is concerned, you basically need loop through your array of "bits", taking 16 at time since you said you have 16-bit values. It's not clear from your code whether your eventual goal is to get a numeric value or a string. This does not appear to be a subVI, so a simply numeric indicator formatted to display in hex format should be quite adequate. The array you are generating is an array of rings, whose datatype is I32, but they will have values of 0 or 1. You can use the example just posted, or you can use the attached variation.
    Attachments:
    Bits to Hex 2.vi ‏17 KB

  • Pushing array into array

    lets say I have
    var myAr:Array = new Array(value, value2, value3);
    var holdAr:Array = new Array();
    holdAr.push(myAr);
    when I trace out holdAr: value, value2, value3
    however, if I trace out holdAr[0], I get the same as tracing
    holdAr.... how can I push an array into a new array and keep the
    indexes?

    You are only adding one element to the array holdAr. That
    element is an array with three indices. I think you need to add the
    elements one at a time to get what you're looking for.

  • Array into cluster

    How do I input an array into the middle of a cluster?
    Thanks

    It does not really help if you keep repeating cryptic messages.
    A cluster has no "middle"!
    Why don't you attach a VI that has reasonable input values as control defaults and an indicator with the desired cluster, again containing the desired outcome as default value. This way we can easily see what you actually mean. Thanks!
    LabVIEW Champion . Do more with less code and in less time .

  • How do you add an object to a collection typed witha wildcard?

    Hi All,
    I want to add an object to a collection typed with a wildcard but I can't figure out how to do it.
    I've been thru the generics tutorial again and I now understand that I can't do exactly what I want to and why. However I don't know how to do it right. I copy some code below to show the problem:
    private List<? extends HasCriteria> dataList;
    private HasCriteria dataObject;
    public HasCriteria getDataObject() {
            return dataObject;
    public List<? extends HasCriteria> getCollection() {
            if(dataList==null){
                refreshDataCollection();
            return dataList;
       }/*I want to be able to do the add() below but the generics tutorial assures me, as does the compiler, that I can't. So how do I get an object into the collection?? */
    public void create(){
    getCollection().add(getDataObject());
    }/*I don't understand why I can do this setCollection() call below as the compiler has no idea that the resultList is of type HasCriteria, however I accept that it is ok with this*/
    protected <T extends HasCriteria> void setCollection(Collection<T> m) {
                dataList = new ArrayList<T>(m) ;
                for(HasCriteria t: dataList){
                    t.setStatus(HasCriteria.Status.SAVED);
    public void refreshDataCollection(String jpaQL, List modelParameters){
                Query q = em.createQuery(jpaQL);
                List rl = q.getResultList();
                if(rl != null){
                    setCollection(rl);
                    setModelQuery(jpaQL, modelParameters);  
    }

    class GenGen <K extends Shape> {
      private List<K> dataList;
      private K dataObject;
      public K getDataObject() {
        return dataObject;
      public List<K> getCollection() {
        if(dataList==null){
          //refreshDataCollection();
        return dataList;
      public void create(){
        getCollection().add(getDataObject());
      protected void setCollection(Collection<K> m) {
        dataList = new ArrayList<K>(m) ;
        for(Shape t: dataList){
          // t.setStatus(HasCriteria.Status.SAVED);
      public void refreshDataCollection(String jpaQL, List modelParameters){
        List rl = null;
        setCollection(rl);
    }Note that in that final setCollection, you'll get an unchecked conversion warning, if you haven't turned them off.

Maybe you are looking for