Programming

HomeProgramming
 
 
- Advertisement -
- Advertisement -
- Advertisement -

JAVA

HIBERNATE

VBSCRIPT

MAVEN

PROGRAMMING POSTS

Concatenate Strings Using String Joiner

Java 8 has added a new class called StringJoiner. This concatenates Strings using a delimiter as well as adds a prefix and suffix to the concatenated String. Performance-wise, it is similar to StringBuffer.append, but it has the added advantage that it automatically adds a delimiter, prefix and suffix. The following...

Concatenate Strings Using String.join() for Collections

There is an overloaded version of the String.join method that accepts as parameter an Iterable implementation. Since all Collection classes implement the Iterable interface, this method can be used to concatenate all the elements in a Collection. The following code demonstrates this: This code creates a List of String values...

Concatenate Strings Using String.join()

Java 8 has added a static join method to the String class. This concatenates Strings using a delimiter. Performance wise, it is similar to StringBuffer.append, but it has the added advantage that it automatically adds a delimiter. As before, this code creates string1 and string2. It invokes the join...

Concatenate Strings Using StringBuilder.append()

In addition to String, Java has the java.lang.StringBuffer and java.lang.StringBuilder classes. These can also be used to concatenate Strings. The advantage of these classes is that both these classes are mutable, so using them does not result in the creation of new String objects. So StringBuffer and StringBuilder...
- Advertisement -

Concatenate Strings Using StringBuffer.append()

In addition to String, Java has the java.lang.StringBuffer and java.lang.StringBuilder classes. These can also be used to concatenate Strings. The advantage of these classes is that both these classes are mutable, so using them does not result in the creation of new String objects. So StringBuffer and StringBuilder...

Concatenate Strings Using String.concat()

The String class has a method called concat. It accepts as parameter a String value and concatenates it with the current String. The following code demonstrates this: As before, this code creates string1 and string2. It then invokes the concat() method on string1 and passes string2 as an argument....

Concatenate Strings Using Plus Operator

In Java, a String is a sequence of characters. There are often programming situations where you will need to concatenate Strings. There are several ways in which you can achieve this. The + operator is also known as the concatenation operator. It can be used to concatenate Strings. The...

Remove Duplicates from List Using Stream

Java 8 has added the Stream API that helps to easily perform bulk operations on Collections. A new method called stream() method has been added to all the collection interfaces that returns a Stream corresponding to the underlying collection. The Stream interface has a method called distinct that can...
- Advertisement -

Java Tutorial #2 – Operators in Java

Table of Contents Introduction 1. Assignment Operator 2. Arithmetic Operators 3. Compound Operators 4. Increment & Decrement Operators 5. Relational Operators 6. Logical Operators Introduction Operators are an essential part of any programming language. In-fact it is not possible not to write a decent piece of code without making use of 'Operators'. Java operators...

Convert List to Array Using ToArray With Param

There is an overloaded version of the toArray method. This accepts an array as a parameter and returns a result array that is of the same data type as the input array. So basically, this toArray  method can be used to obtain an array that is of the same data type...

Remove Duplicates from List Using Set.addAll

The Set interface has a method called addAll. This accepts a 'Collection' as the parameter. So if you invoke this method by passing the 'List', the duplicates will be eliminated. The following code snippet demonstrates this method. Here, a new LinkedHashSet is created and the addAll method is invoked by...

CODE GISTS

Convert String to Date Using SimpleDateFormat Class

Sometimes, you may need to convert a String to a java.util.Date object. For this, you need to use the SimpleDateFormat class. You need to...

Remove Duplicates from List Using HashSet

The Set is also an interface in the 'Java Collection' framework. Unlike a List, a Set does not allow duplicates. Hence you can...

How To Setup Automatic SSH-Agent for GitBash

Using below procedure, you shall be able to setup SSH-Agent to run automatically whenever GitBash is launched on Windows. The ssh-agent process will continue...

Convert List to Array Using ToArray With Param

There is an overloaded version of the toArray method. This accepts an array as a parameter and returns a result array that is of the same...

POPULAR | TAGS

TOP | CATEGORIES