DbSchema is a super-flexible database designer, which can take you from designing the DB with your team all the way to safely deploying the schema.
The way it does all of that is by using a design model, a database-independent image of the schema, which can be shared in a team using GIT and compared or deployed on to any database.
And, of course, it can be heavily visual, allowing you to interact with the database using diagrams, visually compose queries, explore the data, generate random data, import data or build HTML5 database reports.
The Kubernetes ecosystem is huge and quite complex, so it’s easy to forget about costs when trying out all of the exciting tools.
To avoid overspending on your Kubernetes cluster, definitely have a look at the free K8s cost monitoring tool from the automation platform CAST AI. You can view your costs in real time, allocate them, calculate burn rates for projects, spot anomalies or spikes, and get insightful reports you can share with your team.
Connect your cluster and start monitoring your K8s costs right away:
You can get some real insight into your CI pipelines, and into your tests by using Foresight.
This includes not just the basics but some actual, actionable data like Change Impact Analysis, where we can see the changes in a PR and correlate them to test runs and test coverage to show how they affect our builds:
In this tutorial, we'll learn about Enumeration and Iterator in Java. We'll also learn how to use them in code and what are the differences between them.
2. Introduction to Enumeration and Iterator
In this section, we'll learn about Enumeration and Iterator conceptually and their use.
2.1. Enumeration
Enumeration has been present in Java since version 1.0. It's an interface and any implementation allows one to access elements one by one. In simple terms, it's used to iterate over a collection of objects such as Vector and Hashtable.
Let's look at an example for Enumeration:
Vector<Person> people = new Vector<>(getPersons());
Enumeration<Person> enumeration = people.elements();
while (enumeration.hasMoreElements()) {
System.out.println("First Name = " + enumeration.nextElement().getFirstName());
}
Here, we're printing firstName of a Person using Enumeration. The elements() method provides a reference to Enumeration and by using that we can access elements one by one.
2.2. Iterator
Iterator has been present in Java since 1.2 and is used to iterate over collections that were also introduced in the same version.
Next, let's print firstName of a Person using Iterator. iterator() provides a reference to Iterator and by using that we can access elements one by one:
List<Person> persons = getPersons();
Iterator<Person> iterator = persons.iterator();
while (iterator.hasNext()) {
System.out.println("First Name = " + iterator.next().getFirstName());
}
So, we can see Enumeration and Iterator are both present in Java since 1.0 and 1.2 respectively, and are used to iterate over a collection of objects one at a time.
3. Difference Between Enumeration and Iterator
In this table, we'll understand the differences between Enumeration and Iterator:
Enumeration
Iterator
Present since Java 1.0 to enumerate Vectors and Hashtables
Present since Java 1.2 to iterate over Collections such as List, Set, Map, etc
Contains two methods: hasMoreElements() and nextElement()
Contains three methods: hasNext(), next() and remove()
Methods have long names
Methods have short and concise names
Have no methods to remove elements while iterating
Have to remove() to remove elements while iterating
asIterator() added in Java 9 gives Iterator on the top of Enumeration. However, remove() in this particular case throws UnsupportedOperationException
forEachRemaining() added in Java 8 performs actions on the remaining elements
4. Conclusion
In this article, we've understood Enumeration and Iterator, how to use them using code examples, and the various differences between them.
All the code example used in this article is available over on GitHub.
Course – LS – All
Get started with Spring 5 and Spring Boot 2, through the Learn Spring course: