পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Thursday, February 2, 2017

Groovy - Lists

The List is a structure used to store a collection of data items. In Groovy, the List holds a sequence of object references. Object references in a List occupy a position in the sequence and are distinguished by an integer index. A List literal is presented as a series of objects separated by commas and enclosed in square brackets.

To process the data in a list, we must be able to access individual elements. Groovy Lists are indexed using the indexing operator []. List indices start at zero, which refers to the first element.
Following are some example of lists −
  • [11, 12, 13, 14] – A list of integer values
  • [‘Angular’, ‘Groovy’, ‘Java’] – A list of Strings
  • [1, 2, [3, 4], 5] – A nested list
  • [‘Groovy’, 21, 2.11] – A heterogeneous list of object references
  • [ ] – An empty list
In this chapter, we will discuss the list methods available in Groovy.
S.No. Methods & Description
1 add() Append the new value to the end of this List.
2 contains() Returns true if this List contains the specified value.
3 get() Returns the element at the specified position in this List.
4 isEmpty() Returns true if this List contains no elements
5 minus() Creates a new List composed of the elements of the original without those specified in the collection.
6 plus() Creates a new List composed of the elements of the original together with those specified in the collection.
7 pop() Removes the last item from this List
8 remove() Removes the element at the specified position in this List.
9 reverse() Create a new List that is the reverse the elements of the original List
10 size() Obtains the number of elements in this List.
11 sort() Returns a sorted copy of the original List.

No comments:

Post a Comment