Java using Eclipse ADT -


I'm using Eclipse ADT to learn. I used ADT for an introduction to the Android course on Mooc Koresra platform. By going through that course, I know that learning Java is important.

I am working through a java book: Mike MacGrath will go through easy steps

This is teaching a lesson: The code which I have written in a debating passing ADT It is entered:

  package com.javatutorial.hello; Public class options {public static zero main (string [] args) {if (args [0] .equals ("-en") {System.out.println ("English option"); } Else if (args [0] .equals ("-es") {System.out.println ("Spanish option"); } Else System.out.println ("unrecognized option"); }}   

I get an exception error when I run the program:

  Exceptions to the thread "main" java .lang .ArrayIndexOutOfBoundsException: 0 at com.javatutorial.hello.Option.Main (option.java))  

So far I have detected the solutions I have run into problems, but its Need help for this one. Thank you in advance for your help.

You probably do not give any argument to the function. In the run dialog, you have to set the argument in the program. If it is not set correctly, then your index is invalid.

Alternatively, you can check that the args is checked correctly with the option

  if (args. Length = 1) {// now try to index the arguments}  

This prevents ArrayIndexOutOfBoundsException correctly in that case that the user needs to pass an option is not.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -