Methods of StringBuffer Class in Java

Manikanth Mani
Updated on 30-Jul-2019 22:30:21

370 Views

Following are the various constructors provided by the StringBuffer class.S.N.Constructor & Description1StringBuffer()This constructs a string buffer with no characters in it and an initial capacity of 16 characters.2StringBuffer(CharSequence seq)This constructs a string buffer that contains the same characters as the specified CharSequence.3StringBuffer(int capacity)This constructs a string buffer with no characters in it and the specified initial capacity.4StringBuffer(String str)This constructs a string buffer initialized to the contents of the specified string.

Sort ArrayList in Java in Descending Order

V Jyothi
Updated on 30-Jul-2019 22:30:21

7K+ Views

To sort the contents of an ArrayList in descending orderCreate an ArrayList.Sort the contents of the ArrayList using the sort() method of the Collections class.Then, reverse array list using the reverse() method of the Collections class.Example:import java.util.ArrayList; import java.util.Collections; public class ArrayListSample {    public static void main(String[] args) {       ArrayList list = new ArrayList();       list.add("JavaFx");       list.add("Java");       list.add("WebGL");       list.add("OpenCV");       Collections.sort(list);       System.out.println(list);       Collections.reverse(list);       System.out.println(list);    } }Output:[Java, JavaFx, OpenCV, WebGL] [WebGL, OpenCV, JavaFx, Java]

Convert Byte Array to Hex String in Java

Rahul Sharma
Updated on 30-Jul-2019 22:30:21

739 Views

Use Integer.toString(int, redix) where int is byte to be converted and redix is 16 for hexadecimal format.

What Does intern() Method in Java Do?

Ayyan
Updated on 30-Jul-2019 22:30:21

294 Views

The intern() method of the String method returns a canonical representation for the string object. A pool of strings, initially empty, is maintained privately by the class String.For any two strings s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true.All literal strings and string-valued constant expressions are interned.Example Live Demoimport java.lang.*; public class StringDemo {    public static void main(String[] args) {       String str1 = "This is TutorialsPoint";       // returns canonical representation for the string object       String str2 = str1.intern();             // prints ... Read More

Replace Element of an ArrayList in Java

Priya Pallavi
Updated on 30-Jul-2019 22:30:21

9K+ Views

You can replace an element of an ArrayList using the set() method of the Collections class. This method accepts two parameters an integer parameter indicating the index of the element to be replaced and an element to replace with.Example Live Demoimport java.util.ArrayList; public class ArrayListSample {    public static void main(String[] args) {       ArrayList list = new ArrayList();       list.add("JavaFx");       list.add("Java");       list.add("WebGL");       list.add("OpenCV");       System.out.println(list);       list.set(2, "HBase");       System.out.println(list);    } }Output[JavaFx, Java, WebGL, OpenCV] [JavaFx, Java, HBase, OpenCV]

Convert int to String in Java

Manikanth Mani
Updated on 30-Jul-2019 22:30:21

368 Views

You can convert a String value to an integer either using the valueOf() method of the String class or using the toString() method of the Integer class.

Are MySQL Database and Table Names Case Sensitive?

Monica Mona
Updated on 30-Jul-2019 22:30:21

984 Views

Actually, the case sensitivity of database and table name depends a lot on the case sensitivity of the underlying operating system. Hence, we can say that such names are not case sensitive in Windows but are case sensitive in most varieties of Unix.

Set Outline Color with JavaScript

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

518 Views

To set outline color, use the outlineColor property in JavaScript. You can try to run the following code to learn how to implement outlineColor property − Example Live Demo #box { border: 2px solid red; } Demo Content Change outline color function display() { document.getElementById("box").style.outlineColor = "#FF5733"; document.getElementById("box").style.outline = "2px solid"; }

Convert Comma Separated String to ArrayList in Java

Sravani S
Updated on 30-Jul-2019 22:30:21

10K+ Views

To convert a comma separated String into an ArrayListSplit the String into an array of Strings using the split() method.Now, convert the obtained String array to list using the asList() method of the Arrays class.Example Live Demoimport java.util.Arrays; import java.util.List; public class Sample {    public static void main(String[] args) {       String myString = "JavaFx,Java,WebGL,OpenCV";       String[] myArray = myString.split(",");       System.out.println("Contents of the array ::"+Arrays.toString(myArray));       List myList = Arrays.asList(myArray);    } }OutputContents of the array ::[JavaFx, Java, WebGL, OpenCV]

Executing SQL Query in SAP HANA Studio

John SAP
Updated on 30-Jul-2019 22:30:21

2K+ Views

To run the query, click on green arrow button on top right corner  or press F8.

Advertisements