Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2411 of 3363
682 Views
An Iterator is used for cycling through a Collection of objects. Whereas a List is an Interface which is used for storing an ordered collection of elements. Both classes are part of the Java Collections Framework.Converting an Iterator to a List in Java Sometimes we need to convert an Iterator to a collection. In this article, we will learn how to convert an Iterator to a List in Java using multiple ways. Those are: Using a while loop Using Iterator.forEachRemaining() Using Stream API Let's understand each of them in ... Read More
8K+ Views
Gson is a library in the Java that is mainly used for converting Java objects to JSON and vice versa. By default, the Gson object does not serialize the fields with null values to JSON. If a field in a Java object is null, Gson excludes it.Serializing a Null Field Using Gson We can force Gson to serialize null values via the GsonBuilder class. We need to call the serializeNulls() method on the GsonBuilder instance before creating the Gson object. Once serializeNulls() has been called, the Gson instance created by the GsonBuilder can include null fields in the serialized JSON. ... Read More
391 Views
What is an Iterable?Iterable is an Interface that is used for iterating over a Collection of objects. It is part of the Java Collections Framework. The Iterable interface is implemented by all the collection classes in Java. For example, ArrayList, HashSet, etc. The Iterable interface has a method named iterator() which returns an Iterator object.What is a Stream? Stream is an Interface that is used for processing sequences of elements. It is part of the Java Collections Framework. The Stream interface is a newly added abstraction in Java 8. It is mainly used for sequential operations on collections, for example, ... Read More
384 Views
In Java, we can store objects within other objects. A collection is an object that stores other objects. Some examples of collections are ArrayList, HashSet. Iterable is an Interface that is used for iterating over a Collection of objects. It is part of the Java Collections Framework. The Iterable interface is implemented by all the collection classes in Java. The Iterable interface has a method named iterator() which returns an Iterator object. In this article, we will learn how to convert an Iterable to a Collection in Java using multiple ways. Those are - Using for-each ... Read More
632 Views
In this article, we will learn to convert a string to a double in Java. Problem Statement Given a string representing a decimal number, convert it into a double in Java. The input string is guaranteed to be a valid numeric representation. Input: String str = "23.6"; Output: 23 Converting String to Double in Java The following are the different approaches for converting a string to a double in Java - Using Double.parseDouble() Using Double.valueOf() Using String to Double Constructor Using DecimalFormat ... Read More
919 Views
In this article, we will learn to convert string to date in Java. In Java, dates are provided as strings, and it becomes necessary to convert these strings into Date objects for further processing. Problem Statement The goal is to convert the date strings in various formats into Date or LocalDateTime objects. Input − String date1 ="11/10/2018"; String date2 = "15-Mar-2019 21:11:35"; Output − Thu Oct 11 00:00:00 UTC 2018 Fri Mar 15 21:11:35 UTC 2019 Different Approaches The following are the two different approaches to converting string to date in Java − Using SimpleDateFormat ... Read More
1K+ Views
In this article, we will learn how to convert a string to a list of characters in Java. Sometimes, when we handle character-based data structures, we need to convert a string into a list of characters. In Java, a string is a sequence of characters and is represented by the String class. A list is a collection of elements and is represented by the List interface. Converting a String to a List of Characters The following are the different approaches to convert a string to a list of characters in Java - Using String.toCharArray() ... Read More
3K+ Views
Try-catch, throw, and throws are keywords that are used for handling exceptions in Java. Exceptions are the problems that occur during the execution of a program. When a problem occurs, the program you are trying to run will terminate abnormally. So, to handle these exceptions, Java has a mechanism called exception handling. We handle different types of exceptions, such as runtime exceptions, compile-time exceptions, using try-catch, throw, and throws keywords. Types of Exceptions There are two types of exceptions in Java: Checked Exceptions: These are the exceptions that are checked at compile time. For example, ClassNotFountException, ... Read More
313 Views
In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven an array input of integers, we need to find whether it’s possible to make an integer using all the digits available in these numbers such that it would be divisible by 3.Here we will generate a function that will take two arguments namely the array of integers and the length of the array.The implementation given below works on the concept from the mental mathematics. Here we observe that a number is divisible by 3 if the sum of the digits are divisible ... Read More
9K+ Views
In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven a string input, we need to generate a Python program to check whether that string is Pangram or not.A pangram is a sentence/ series of words which contains every letter in the English Alphabets collection.Now let’s see how we can solve the problemWe will use a loop that checks whether each character present in the input string belongs to the alphabet set or not which we will declare manually .The implementation of the approach above is given by −Example Live Demoimport string def ... Read More