Search:

Type: Posts; User: Norm

Search: Search took 0.11 seconds.

  1. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    Is your problem solved now?
  2. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    What does that mean?
    Is there a variable for each person? What type is the variable? String or int or a new class you're going to create?
  3. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    short[] aryLa = new short[70];
    With this array definition, the values of the index can be from 0 to 69.
    The element: aryLa[70] does NOT exist.
  4. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    yes, that is the problem

    The contents of the array can be any valid short value. The values of the indexes into the array can only be from 0 to 69.
  5. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    short[] aryLa = new short[70];
    What is the maximum index value you can have for the array aryLa?
    What is the value of the first index used in your code?
  6. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    Is that what you would expect from the code?

    I would think it would print out forever or until the buffer got full or you stopped the program.

    What code in the loop will stop the loop from...
  7. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    for(aryOneAdder = 0; aryOneAdder < 122;){
    if (aryOneAdder <121){
    aryOneAdder++;
    }
    aryOne[aryOneAdder] = aryOne[1];
    ...
  8. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    What is it supposed to output? Can you explain what the code is supposed to do to generate its output?

    Perhaps you should post the current version of the program with an explanation of what it is...
  9. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    ??? The last post showed that the output was the numbers from 1 to 121
  10. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    Ok. Is your problem solved now?
  11. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    What is the contents of: aryOne[1] ?
    You are copying it into all of the elements of the array?
    If it contains 0 then your program is working as I'd expect it to.
  12. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    import java.util.Arrays;
  13. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    What source line is at line 21?
    What import statements do you have in your program?
    You need to import the package that the Arrays class is in?
  14. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    To see what is in the array after your code executes use this:

    System.out.println(Arrays.toString(aryOne)); // Show array's contents
  15. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    Try playing computer with your program to see how how the values of the variables change.
    Go thru the code line by line and record what variables are set to what values.

    At the end what is the...
  16. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    Magic. Or you've got a ghost changing your program.
  17. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    There is important info in the error message, please copy and paste here the full text of the message.

    It looks like you create the array AFTER you try to use it.
    Create the array BEFORE you use...
  18. Thread: Array and loops.

    by Norm
    Replies
    46
    Views
    5,254

    Re: Array and loops.

    byte[] aryOne = new byte[aryOneAdder]; // Create a new byte array with aryOneAdder elements

    Your loop creates a new array every time it loops. That replaces the one that was created on the last...
Results 1 to 18 of 18