On Jul 25, 1:00 pm, Radhika.K <[email protected]> wrote: > public void ListToArray() { > > List<String> carList = new ArrayList<String>(); > > carList.add("Dodge"); > carList.add("Chevrolet"); > carList.add("BMW"); > carList.add("Toyota"); > > String[] carArray = carList.toArray(new String[0]); > > for (String car : carArray) { > System.out.println(car); > } > } > > public static void main(String[] args) { > new roughClass1().ListToArray(); > } > } > > "C:\Program Files\Jdeveloper\Jdev10.1.3.3\jdk\bin\javaw.exe" -client > -classpath "C:\Program > Files\Jdeveloper\Jdev10.1.3.3\jdev\mywork\rough\rough1\classes" > -Dhttp.proxyHost=192.168.107.244 -Dhttp.proxyPort=8080 > -Dhttp.nonProxyHosts=localhost|127.0.0.1 -Dhttps.proxyHost=192.168.107.244 > -Dhttps.proxyPort=8080 -Dhttps.nonProxyHosts=localhost|127.0.0.1 > rough1.roughClass1 > Addition of two numbers! > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 Generated exception:ArrayIndexOutOfBoundsException indicates to a fault somewhere else. toArray() do not potentially generate this exception. > at rough1.roughClass1.main(roughClass1.java:33) > Process exited with exit code 1. > > Can u pls tel me how to declare a array n make this pgm run.. > > Thanks & Regards, > Radhika.K
--~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
