
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
Found 33676 Articles for Programming

6K+ Views
In this article, we will learn the different approaches to replace a part of a string with another string using a C/C++ program. The problem statement of this program is explained below: The input of this problem will be three strings. The task is to replace all the occurrence of the second string with the third string inside the first string. For example: // Input strings "C++ Course is free on Tutorialspoint" "C++" "Python" // Output String "Python Course is free on Tutorialspoint" Replace a Substring With Another String Here is the list of all ... Read More

4K+ Views
Trailing zeros are the zero occuring at the end of a string. In this article, we will discuss different approaches to remove trailing zeros from a string. The below section explains the problem statement. The input of this problem is a non-empty string containing characters and numbers. Our task is to remove all the zero's appering after the last non-zero character in the string. For example: // Input string "012424000" // Output String "012424" Remove Trailing Zeros From String Here is the list of approaches to remove all the trailing zeros from a string ... Read More

17K+ Views
In this article, we will learn all the different approaches to remove the whitespaces from a standard string in C/C++. First of all, let's understand our problem statement. The input of this problem is a non-empty string containing multiple characters and whitespaces between those characters. Our task is to print the string by ignoring all the whitespaces into the output console. For example: // Input String "This is a string" // Output String "Thisisastring" Remove Whitespaces from a String in C++ Here is the list of approaches to remove all the whitespaces from a string using ... Read More

570 Views
Sometimes, in C++ when you try to print a string that containing special characters like escape sequences (), backslashes (\), or quotes(""), the output may not be as expected. To avoid this, C++ provides a feature called raw string literal. In this article, we will discuss what is raw string literal and how to use it in C++. What is Raw String Literal? A raw string literal in C++ is a type of string that preserves the formatting of the string content without changing any escape sequences such as "", "\t", or "". This is useful when you want ... Read More

988 Views
The mapToInt() method returns an IntStream consisting of the results of applying the given function to the elements of this stream.The syntax is as followsmapToInt(LongToIntFunction mapper)Here, the parameter mapper is the stateless function applied to each element.Declare LongStream and add some elementsLongStream longStream = LongStream.of(1000L, 13000L, 18000L);Now, use the IntStream and mapToInt()IntStream intStream = longStream.mapToInt(val -> (int) val);The following is an example to implement LongStream mapToInt() in JavaExample Live Demoimport java.util.*; import java.util.stream.IntStream; import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(1000L, 13000L, 18000L); IntStream intStream = ... Read More

432 Views
The AbstractSequentialList class provides an implementation of the List interface. For an unmodifiable list, implement the list iterator's hasNext, next, hasPrevious, previous and index methods. For a modifiable list the programmer should implement the list iterator's set method.The syntax is as followspublic abstract class AbstractSequentialList extends AbstractListTo work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;First, create an AbstractSequentialList classAbstractSequentialList absSequential = new LinkedList();Now, add elementsabsSequential.add("Accessories"); absSequential.add("Home Decor"); absSequential.add("Books"); bsSequential.add("Stationery");Let us see an example to implement the AbstractSequentialList class in JavaExample Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] ... Read More

328 Views
The toString() method of the AbstractCollection class is used to return the string representation of the elements of this collection.The syntax is as followspublic String toString()To work with AbstractCollection class in Java, import the following packageimport java.util.AbstractCollection;The following is an example to implement AbstractCollection toString() method in JavaExample Live Demoimport java.util.ArrayList; import java.util.AbstractCollection; public class Demo { public static void main(String[] args) { AbstractCollection absCollection = new ArrayList(); absCollection.add("HDD"); absCollection.add("Earphone"); absCollection.add("Headphone"); absCollection.add("Card Reader"); absCollection.add("SSD"); absCollection.add("Pen Drive"); ... Read More

144 Views
The difference between toArray() and toArray(T[] arr) in Java AbstractCollection is that both the methods returns an array containing all of the elements in this collection, but the latter has some additional features i.e. the runtime type of the returned array is that of the specified array.The syntax is as followspublic T[] toArray(T[] arr)Here, arr is the array into which the elements of this collection are to be stored.To work with AbstractCollection class in Java, import the following packageimport java.util.AbstractCollection;The following is an example to implement AbstractCollection toArray() method in JavaExample Live Demoimport java.util.ArrayList; import java.util.AbstractCollection; public class Demo { ... Read More

108 Views
To add elements to the ArrayBlockingQueue class, use the add() method.The syntax is as followsboolean add(E ele)Here, ele is the element to be added to the queue. To work with ArrayBlockingQueue class, you need to import the following packageimport java.util.concurrent.ArrayBlockingQueue;The following is an example to add elements in Java ArrayBlockingQueue classExample Live Demoimport java.util.concurrent.ArrayBlockingQueue; public class Demo { public static void main(String[] args) { ArrayBlockingQueue q = new ArrayBlockingQueue(7); q.add(100); q.add(250); q.add(300); q.add(450); q.add(550); q.add(600); q.add(700); System.out.println("ArrayBlockingQueue = " + q); } }OutputArrayBlockingQueue = [100, 250, 300, 450, 550, 600, 700]