Groovy - Create a generic List collection, append the items Code Example

The code for Create a generic List collection, append the items

class Program {
   static void main(String[] args) {
      // Creating a generic List collection
      List<String> cities = new ArrayList<String>();
      cities.add("Gwalior");
      cities.add("New Delhi");
      cities.add("Bhopal");
		
      for(String city : cities) {
         println(city);
      }
   } 
}

/*
Output:

Gwalior
New Delhi
Bhopal
*/
Code by IncludeHelp, on August 9, 2022 15:43

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.