import java.io.*;
import java.util.*;
class MyClass
{
	public static void main(String s[])
	{
		int a,b;
		a = Integer.parseInt(s[0]);
		b = Integer.parseInt(s[1]);
	System.out.print("Hello World \n");
	}
}

I'm getting the following error " Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at MyClass.main(Myclass.java:8) "

Someone please help me out.....

Recommended Answers

All 3 Replies

did you pass command line parameters, or just expect it to 'magically work' no matter what instruction you gave to run the application?

s[] obviously is of size 0, so index 0 is out of bounds.
Did you pass in any parameters when you ran this?

Merged duplicate threads.

@casinoua: please do not create multiple threads for the same question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.