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.
initialize array amount of elements going store in array:
double[] mylist = new double[2];
assign double specific place in array:
mylist[0] = bob.nextdouble(); mylist[1] = bob.nextdouble();
Comments
Post a Comment