fork download
  1. //Defining array
  2. String [] arrayOfProducts = new List<String>();
  3.  
  4. //Adding elements in Array
  5. arrayOfProducts.add('HCL');
  6. arrayOfProducts.add('H2SO4');
  7. arrayOfProducts.add('NACL');
  8. arrayOfProducts.add('H2O');
  9. arrayOfProducts.add('N2');
  10. arrayOfProducts.add('U296');
  11.  
  12. for (Integer i = 0; i<arrayOfProducts.size(); i++) {
  13. //This loop will print all the elements in array
  14. system.out.println('Values In Array: '+arrayOfProducts[i]);
  15. }
Success #stdin #stdout #stderr 0.01s 7784KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
./prog:1: expected expression