0

I want to start a program in Eclipse with input parameters (max: calculates max of two integers). If I click on run, there is no input prompt, and I get error message:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at BerechnungenSample.main(BerechnungenSample.java:10)

What's the best way to do this?

Btw: Is there a difference in Java between "arguments" and "variables"?

Thanks alot Markus

Mickael
  • 3,506
  • 1
  • 21
  • 33
Markus C.
  • 1
  • 1
  • Post code please –  Sep 04 '17 at 16:01
  • If you don't provide the code, there is no way to tell what is causing the exception. – Anna P. Sep 04 '17 at 16:03
  • You're trying to access the first element of an empty array. Make sure you correctly initialized the arrays you're using. – Aaron Sep 04 '17 at 16:03
  • 1
    What you wanna do is described here: https://stackoverflow.com/questions/373328/invoking-java-main-method-with-parameters-from-eclipse You wanna pass parameters to the main method. You can do this in eclipse by pressing "Run As" and configure your parameter configuration there. – Tom Stein Sep 04 '17 at 16:07
  • Is there a difference in Java between "arguments" and "variables"? - sure, you might want to read up on this in any tutorial. You might get different definitions but basically you could think of it like this: variables are references to values which can be different (or variable) at runtime (other than constants) while arguments are things that are passed to something you call (in case of methods they're normally called parameters). I assume most people use "variable" for method-local variables and other names for other variable things (like parameters, fields, etc.). – Thomas Sep 04 '17 at 16:12
  • where is your code, please clarify what you wanna do, this error is because of `out of range` index – Mohsen_Fatemi Sep 04 '17 at 18:59

0 Answers0