StringBuffer Reset Java Example

Here is a simple program for StringBuffer Reset in Java: /* StringBuffer Reset Java Example This example shows how to reset StringBuffer object to null or empty vale using delete method. */ public class StrinBufferResetExample { public static void main(String[] args) { //create StringBuffer object StringBuffer sbf = new StringBuffer(“Hello World!”); System.out.println(“StringBuffer content: ” + … Read more

Linear Search in Java

What is Linear Search? Linear search or sequential search is a method for finding a particular value in a list that checks each element in sequence until the desired element is found or the list is exhausted. Its worst case cost is proportional to the number of elements in the list. Its expected cost is … Read more

Java StringBuffer to InputStream Example

Here is the program to convert StringBuffer to InputStream: /* Java StringBuffer to InputStream Example This example shows how to convert StringBuffer to InputStream in Java using ByteInputStream class. */ import java.io.ByteArrayInputStream; import java.io.InputStream; public class StringBufferToInputStreamExample { public static void main(String args[]){ //create StringBuffer object StringBuffer sbf = new StringBuffer(“StringBuffer to InputStream Example”); /* … Read more

Java StringBuffer append new line example

[ad_1] /* Java StringBuffer append new line example This example shows how to append new line in StringBuffer in Java using append method. */   public class JavaStringBufferAppendNewLineExample { public static void main(String args[]){ //create StringBuffer object StringBuffer sbf = new StringBuffer(“This is the first line.”); /* * To append new line to StringBuffer in … Read more

StringBuffer To byte Array Java Example

[ad_1] /* StringBuffer To byte Array Java Example This example shows how to convert StringBuffer to byte Array in Java. */     public class StringBufferToByteArrayExample { public static void main(String[] args) { //create StringBuffer object StringBuffer sbf = new StringBuffer(“Java StringBuffer To byte array example”); /* * To Convert StringBuffer to byte array, first … Read more

Java StringBuffer setLength Example

[ad_1] /* Java StringBuffer setLength Example This example shows how to set length of StringBuffer using setLength method of StringBuffer class in Java. */   public class JavaStringBufferSetLengthExample { public static void main(String[] args) { //create StringBuffer object StringBuffer sbf = new StringBuffer(“StringBuffer setLength method example”); /* * To set length of StringBuffer, use * … Read more