Found 33676 Articles for Programming

The add() method in Java Stream.Builder

Nancy Den
Updated on 30-Jul-2019 22:30:25

569 Views

Use the add() method to insert elements in the Stream.Builder. The element to be added is a parameter for the add().The following is the syntax:default Stream.Builder add(T t)Here, t is the element to be added.Import the following package for the Stream.Builder class in Java:import java.util.stream.Stream;At first, create Stream.Builder:Stream.Builder builder = Stream.builder();Now, add elements using add() method:builder.add("This"); builder.add("is"); builder.add("it!");Here is an example displaying how to implement add() method of Stream.Builder in Java:Example Live Demoimport java.util.stream.Stream; public class Demo {    public static void main(String[] args) {       Stream.Builder builder = Stream.builder();       builder.add("This");       builder.add("is");   ... Read More

Wrapping C/C++ for Python using SWIG

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

2K+ Views

There are multiple ways to wrap your existing C or C++ functionality in Python. In this section, we are going to see how we can wrap C/C++ functionality with SWIG. Below are other options to wrap c/c++ functionality in python.Manual wrappingUsing pyrex to wrap C code.CtypesSIPBoost PythonSWIG (Simple Wrapper Interface Generator) is capable of wrapping C code with numerous other languages including Perl, Python, PHP, Ruby, Tcl, C#, Common Lisp (CLISP, Allegro, CL, UFFI, CFFI), Java, Modula-3 and OCAML. Swig also supports multiple interpreted and compiled Scheme implementations (like Guile, MzScheme, Chicken) are supported.But we will discuss its implementation with ... Read More

StringJoiner toString() method in Java 8

Nancy Den
Updated on 30-Jul-2019 22:30:25

292 Views

The toString() method of the StringJoiner class in Java8 is used to return the string representation of the StringJoiner.The syntax of the toString() method is as follows:String toString()To work with the StringJoiner in Java 8, import the following package:import java.util.StringJoiner;The following is an example to implement StringJoiner toString() method in Java:Example Live Demoimport java.util.StringJoiner; public class Demo {    public static void main(String[] args) {       StringJoiner strJoin = new StringJoiner(" ");       strJoin.add("One");       strJoin.add("Two");       strJoin.add("Three");       strJoin.add("Four");       strJoin.add("Five");       System.out.println(strJoin.toString());    } }outputOne ... Read More

What is StringJoiner class in Java 8?

Nancy Den
Updated on 30-Jul-2019 22:30:25

256 Views

The StringJoiner class in Java 8 constructs a sequence of characters. This sequence is separated by a delimiter and optionally starting with a supplied prefix and ending with a supplied suffix.The following are the constructors of the StringJoiner class:StringJoiner(CharSequence delimiter): This constructor constructs a StringJoiner with no characters in it and with no prefix or suffix. It used the copy of the supplied delimiter.StringJoiner(CharSequence delimiter, CharSequence prefix, CharSequence suffix) This constructor constructs a StringJoiner with no characters in it. It uses the copies of the supplied prefix, delimiter and suffix.The syntax is as follows:public final class StringJoiner extends ObjectHere, class ... Read More

Iterate through KeyValue Tuple in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

468 Views

To iterate through the KeyValue tuple in Java, use the Iterable and loop it through using the for loop. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples:Steps: How to run JavaTuples program in EclipseThe following is ... Read More

Part of Speech Tagging with Stop words using NLTK in python?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

263 Views

The main idea behind Natural Language Processing is machine can do some form of analysis or processing without human intervention at least to some level like understanding some part of what the text means or trying to say.While trying to process the text, computers needs to filter out useless or less-important data(words) from the text. In NLTK, useless words(data) are referred to as stop words.Installing Required libraryFirst you need the nltk library, just run the below command in your terminal:$pip install nltkSo we are going to remove these stop words, so they don’t take space in our database or taking ... Read More

Print with your own font using Python?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

443 Views

In this, we are going to see how differently we can display our text in a very unique way using python.So let suppose I want to display “Hello, Python” and out many ways I could display my text/string (“Hello, Python”) like:Input“Hello, Python”Output 1___ ___ .__ .__ / | \ ____ | | | | ____ / ~ \_/ __ \| | | | / _ \ \ Y /\ ___/| |_| |_( ) \___|_ / \___ >____/____/\____/ /\ \/ \/ )/ __________ __ .__ \______ \___.__._/ |_| |__ ____ ____ | ___< | |\ __\ | \ / _ ... Read More

Formatted string literals (f-strings) in Python?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

682 Views

Python now provides new way to format strings, called f-strings. This features is available from Python 3.6 under PEP-498. They are so called (f-string) because of the letter ‘f’ prefix with a string. The letter ‘f’ also indicates that these f-strings can be used for formatting.Below are some of the examples to demonstrates the use of f-strings.Program#1name = 'Rajesh' age = 13 * 3 fString = f'My name is {name} and my age is {age}' print(fString) #We can use Uppercase 'F' instead of lowercase 'f'. print(F'My name is {name} and my age is {age}') #As the fString valuation is done, ... Read More

Image based Steganography using Python?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

937 Views

Steganography is a technique of hiding information behind the scene. It’s is not like cryptography which focuses on encrypting data(through different algorithms like SHA1, MD5 etc), steganography focuses more on hiding the data (data can be a file, image, message or video) within another file, image, message or video to avoid any attraction.So in this we’ll try to create a simple python program that hides the information behind the image without noticiable changes in the looks of the image. There are two main parts of the program – first is a decoding function that can extract secret information from an ... Read More

negate function in C++ STL

Farhan Muhamed
Updated on 15-May-2025 11:23:14

1K+ Views

The negate function in C++, is a function object (functor) that returns the negation of a the given value. In this article, we will learn how to use the negate function from the Standard Template Library (STL) in C++. What is negate? The negate function is a predefined function object defined in the STL that performs arithmetic negation. It takes a single value and returns its negative value. For example, if the input is 5, the output will be -5. This operation is useful when we want to apply negation inside STL algorithms like transform() or for_each() without writing ... Read More

Advertisements