
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Differences between Collection and Collections in Java?
The Collection is an interface whereas Collections is a utility class in Java. The Set, List, and Queue are some of the subinterfaces of Collection interface, a Map interface is also part of the Collections Framework, but it doesn't inherit Collection interface. The important methods of Collection interface are add(), remove(), size(), clear() etc and Collections class contains only static methods like sort(), min(), max(), fill(), copy(), reverse() etc.
Syntax for Collection Interface
public interface Collection<E> extends Iterable<E>
Syntax for Collections class
public class Collections extends Object
Example
import java.util.*; public class CollectionTest { public static void main(String args[]) { ArrayList<Integer> list = new ArrayList<Integer>(); // Adding elements to the ArrayList list.add(5); list.add(20); list.add(35); list.add(50); list.add(65); // Collections.min() method to display minimum value System.out.println("Minimum value: " + Collections.min(list)); // Collections.max() method to display maximum value System.out.println("Maximum value: " + Collections.max(list)); } }
Output
Minimum value: 5 Maximum value: 65
- Related Articles
- Difference between collection and collections in java
- Difference between Traditional Collections and Concurrent Collections in java
- Difference between next() and hasNext() in java collections?
- Difference between Streams and Collections in Java 8
- Difference between Arrays and Collection in Java
- Differences between & and && operators in Java.
- Differences between | and || operators in Java
- Differences between HashMap and Hashtable in Java
- Differences between Interface and class in Java
- Differences between ArrayList and LinkedList in Java
- Differences between Java 8 and Java 9?
- What are the differences between a list collection and an array in C#?
- Collections in Java\n
- Multidimensional Collections in Java
- Major differences between C# and Java

Advertisements