Discuss the below:
Task:
You coded the following in the Test.java class:
ArrayList a = new ArrayList ( );
a. add ("Cloudy");
a. add ("Snowy");
a. add("Cloudy");
System.out.println ( "Weather is " + a. get (3 ) ); // line 14
The code compiles properly, but when you run, you get the following output:
Exception in thread "main" java.land.IndexoutBoundsException:
Index: 3, Size 3
at java.until.ArrayList.RainCheck (ArrayList.java:599
at java.until.ArrayList.get (ArrayList.java:377)
at Test.main (Test.java:14)
Q: Explain what the problem is and how to fix it.