java - Storing doubles in an array -


alright, want store values in array. here code :

import java.util.scanner; public class test {     public static void main(string args[]){         scanner bob = new scanner(system.in);          double[] mylist;          system.out.println("what first value?");         mylist = bob.nextdouble();          system.out.println("what second value?");         mylist = bob.nextdouble();     } } 

issue #1: i'm being told mylist = bob.nextdouble() should nextline(). why if double?

goal: want somehow store values given array later pull them out. can help?

update

for issue #1, tells me cannot convert double() double[]. mean?

mylist array of doubles, not single double.

when mylist = bob.nextdouble(); trying make entire array equal single number.

you instead need assign number specific place in array.

  1. initialize array amount of elements going store in array:

    double[] mylist = new double[2]; 
  2. assign double specific place in array:

    mylist[0] = bob.nextdouble(); mylist[1] = bob.nextdouble(); 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -