arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aiseki
    New Member
    • Apr 2008
    • 2

    arrays

    i currently have an array of 20 numbers. how do i set all the cells in that array to have the same number that is specified by the user?
  • mia023
    New Member
    • May 2007
    • 89

    #2
    Originally posted by aiseki
    i currently have an array of 20 numbers. how do i set all the cells in that array to have the same number that is specified by the user?
    well here is an idea the user enter the numbers so you check if the first number entered by the user is different from the others you will try agin and reenter the data

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by aiseki
      i currently have an array of 20 numbers. how do i set all the cells in that array to have the same number that is specified by the user?
      You could do it the 'mechanical' way by using a loop and setting each and every
      element to that value but that has been done before; have a look at the Arrays
      utility class and this little code snippet:

      [code=java]
      Arrays.fill(you rArray, userSpecifiedVa lue);
      [/code]

      kind regards,

      Jos

      Comment

      • aiseki
        New Member
        • Apr 2008
        • 2

        #4
        thanks guys, that really helped a lot ^^

        Comment

        Working...