Print or list all system properties using java8 streams

System properties are vital for our application development. Sometimes, we need to go through our system properties to trouble shoot our application. In current post, we will list all our system properties. Program – print all system properties using java8 streams. package org.learn; import java.util.Properties; public class ListSystemProperties { public static void main(String[] args) {… Read More »

Find second smallest element in an array of integers (java / example)

Given an array of integers in java. Print second smallest element in an array (in single iteration). We have already discussed to find out second largest element in an array of integers. Example – find second smallest element in an array of integers (java). Example 1: Given an input array  {2, 4, 6, 8, 10, 12}. Smallest element… Read More »

Convert given string to character array in java (with example)

Given an input string in java. Convert input string to char array. We will print each character of char array during iteration. Program – convert String to char array in java package org.learn; public class ConvertStringToArray { public static void main(String[] args) { String inputString = “Internet of things”; System.out.println(“1. Input String is = “… Read More »

Difference b/w length & capacity method (impact of trim) of StringBuffer in java

StringBuffer is a thread-safe, mutable sequence of characters. StringBuffer can be modified at any point of time. We will look into the length and capacity method of StringBuffer class. StringBuffer provides the following methods to play with length & capacity. public int length() Returns the length (character count). public int capacity() Returns the current capacity.… Read More »

Convert String to lower case & upper case in java (with example)

Given a String in java, we would like to convert the input String to lower case and upper case. String class has couple of methods, to convert the input string to lower case & upper case. Method 1: toLowerCase toLowerCase method will convert the input String to lower case. Method 2: toUpperCase toUpperCase method will… Read More »

Difference between == operator & equals method in java (with example)

Difference between equality operator and equals method is very famous interview question. We will look into the important differences, with the help of examples. We will go through the basics of equality operator and equals method. We will summarize the difference between equality operator and equals method. 1. Equality or == operator in java Equality… Read More »

Implement two stacks using single array in java (example)

Given an array of integers in java. Create two stacks using single array. We shall able to perform push & pop operations on both stacks. We will create two stacks i.e. stack1 and stack2. stack1 will have following methods. push1 method: push1 method will insert the element to stack1 pop1 method: pop1 method will remove… Read More »

Page 5 of 41« First...34567...102030...Last »