Hey,
In order to use method ListToArray, you can
either instantiate "roughClass1" or make ListToArray method static.
Your code does not any computation but if You use static method it
will run without errors.
pacior

On Jul 25, 9:00 am, 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
>             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
-~----------~----~----~----~------~----~------~--~---

Reply via email to