wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Understanding the addRange() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Understanding the addRange()" Watch "Understanding the addRange()" New topic
Author

Understanding the addRange()

Jdinesh Tiwari
Ranch Hand

Joined: Jan 13, 2013
Posts: 35


In the specified code above i am unable to understand the addRange() method functionality defined for each collection may help on the same.

Thanks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Can you explain in more detail what exactly you don't understand?

Do you understand the for-loop in line 23? Do you know what the different kinds of collections are and how they work (HashSet, ArrayList, TreeSet, LinkedList)?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jdinesh Tiwari
Ranch Hand

Joined: Jan 13, 2013
Posts: 35
Dear Jesper de Jong

Thanks for your kind consideration on the issue
Yes, i am aware the the collections and for loop specified in the program
problem statement that i am unable to understand in the program how and what exactly these statements are performaing


addRange(set1, 1);

addRange(list1, 2);

addRange(set2, 3);

addRange(list2, 5);

static void addRange(Collection<Integer> col, int step)


Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Those first four lines are calls to the method named addRange, where the method is called with two arguments: a collection of Integer objects and an int.

See Defining Methods and Passing Information to a Method or a Constructor in Oracle's Java Tutorials.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Understanding the addRange()
 
Similar Threads
TreeSet - Object input and output
HashSet and equals()
Linked List equals method
Comparing two collections...
Finish my code please