Ask your own question, for FREE!
Mathematics 8 Online
OpenStudy (anonymous):

help with arrays?

OpenStudy (unklerhaukus):

\[\begin{bmatrix} a & r& r\\ a&y&s\end{bmatrix}?\]

OpenStudy (anonymous):

Given an array iArray of int type, declared to contain 50 elements, and a variable dVar of double type which has been assigned a value. Write an expression that assigns the value stored in the variable dVar to the last element of the array iArray.

OpenStudy (anonymous):

arrays in java

OpenStudy (unklerhaukus):

sorry but i am yet to understand the language java

OpenStudy (anonymous):

okay

OpenStudy (anonymous):

You would have to convert the double value to an int first, so it can be stored into the array. double d = dVar; int i = (int)d; iArray [49] = i;

OpenStudy (anonymous):

Understand?

OpenStudy (anonymous):

iArray[49] = dVar;

OpenStudy (anonymous):

You can't just store dVar into iArray because iArray is an array of int type, dVar is of double type. double d = dVar; //storing the value of dVar in d int i = (int)d; // using cast to convert double to integer iArray [49] = i; // storing the converted value into 50th element of array The first line may be unnecessary, I just like to simply things. You could also have done: int i = (int)dVar; iArray [49] = i; Of course this is assuming, the array iArray and variable dVar have already been declared.

OpenStudy (anonymous):

thanks

OpenStudy (anonymous):

i need with Echo command line...can you help me with that too?

OpenStudy (anonymous):

public class EchoB { public static void main (String[] args) { System.out.println("Hello" + args[0] + " " + args[1]); }} What would be the output from this EchoB program if we invoke this program with the following command? java EchoB "How Are You?"

OpenStudy (anonymous):

Assuming How, Are, You are 3 different arguments. The output would be "HelloHow Are" If it were: public class EchoB { public static void main (String[] args) { System.out.println("Hello" + args[0] + " " + args[1] + args [2]); }} The output would be HelloHow AreYou

hero (hero):

Wow, I could have used this kind of help when I was taking a java course

OpenStudy (anonymous):

can you still help ?

hero (hero):

Please. I gave up on Java a long time ago. The next time I take a Java course, it will be with my personal tutor.

OpenStudy (anonymous):

haha

OpenStudy (anonymous):

go ask this in comp sci

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!