Answers for "string and string buffer"

3

string buffer in java

StringBuffer buffer = new StringBuffer("Harvard"); 
// mutable we modify object
        buffer.append(" School"); 
// append method we are calling from Buffer ** synchronized means slow

        System.out.println(buffer); // Harvard School
Posted by: Guest on June-09-2021
2

string vs stringbuffer

The main similarity between String and StringBuffer class is that both are
thread safe. 
The main difference is that String is immutable; StringBuffer is mutable.
Posted by: Guest on December-05-2020
3

string buffer and string builder

The StringBuffer and StringBuilder 
class both produces mutable string objects.
 The main difference between 
 them is that StringBuffer is thread safe;
 StringBuilder is not thread safe.
Posted by: Guest on January-22-2021
0

Create buffers from strings using the Buffer.from() function. Like toString(), you can pass an encoding argument to Buffer.from().

let buf = Buffer.from('Hello, World', 'utf8');

buf.toString('hex'); // '48656c6c6f2c20576f726c64'
buf.toString('utf8'); // 'Hello, World'

buf = Buffer.from('48656c6c6f2c20576f726c64', 'hex');
buf.toString('utf8'); // 'Hello, World'
Posted by: Guest on May-17-2021
0

difference between string vs stringbuffer

The main similarity between String and StringBuffer class is that both are 
thread safe.
The main difference is that String is immutable; StringBuffer is mutable.
Posted by: Guest on December-05-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language