answersLogoWhite

0

Here's how to create a StringBuffer instance.

StringBuffer sb = new StringBuffer();
sb.append("Add this is to the buffer");
// ...
Note the StringBuffer has synchronized methods so if it is only accessed in a single thread context then a StringBuilder is preferred. StringBuffer and StringBuilder both implement the Appendable and CharSequence interfaces so can be used interchangeably.

User Avatar

Wiki User

10y ago

What else can I help you with?

Continue Learning about Engineering

How do you tell your program you are using a VARIABLE?

You have to declare it. The simplest way to do so is by using the Dim keyword. For example if you want a string variable called someString you would declare it thus: Dim someString as string


Why all variables are declared with in the function?

It is not necessary to to declare variables inside the function in C. If you declare a variable inside a function, the variable becomes local for the function and another variable of same name can be declared in any other function, but you can not use the variable declared in other function. When you declare any variable outside the function body then the variable becomes global and can be used in any function of the program. Note: errno is an example for a variable declared outside any function.


How do you declare local and global variables in pseudo code?

Pseudocode is not a programming language (it's specifically intended for human interpretation), so there is no need to declare variables, you simply define them as and when you require them. For instance: Let x = 42 Let y = x * 2


Why are public instance variable dangerous?

Public instance variables are not dangerous, but can put your program at risk of being hacked. For instance, say the variable bacon is an integer that represents your health in a game, and its value is 50. Someone could change its value to 1,000,000 by using a program called a decompiler, then change the code, and recompile it.


What is uses of const and volatile?

When you declare a const you provide a guarantee to the compiler that the value will never be changed by your program; the value is constant. All constants are implicitly static, so they are always allocated in the program's data segment rather than on the stack. When you declare a variable as being volatile, you are stating to the compiler that the memory referred to by that variable is not under the direct control of your program and that external processes may change the value at any time.

Related Questions

How do you tell your program you are using a VARIABLE?

You have to declare it. The simplest way to do so is by using the Dim keyword. For example if you want a string variable called someString you would declare it thus: Dim someString as string


Why all variables are declared with in the function?

It is not necessary to to declare variables inside the function in C. If you declare a variable inside a function, the variable becomes local for the function and another variable of same name can be declared in any other function, but you can not use the variable declared in other function. When you declare any variable outside the function body then the variable becomes global and can be used in any function of the program. Note: errno is an example for a variable declared outside any function.


How do you declare local and global variables in pseudo code?

Pseudocode is not a programming language (it's specifically intended for human interpretation), so there is no need to declare variables, you simply define them as and when you require them. For instance: Let x = 42 Let y = x * 2


Why are public instance variable dangerous?

Public instance variables are not dangerous, but can put your program at risk of being hacked. For instance, say the variable bacon is an integer that represents your health in a game, and its value is 50. Someone could change its value to 1,000,000 by using a program called a decompiler, then change the code, and recompile it.


What is the difference between declaring static variable as local and global?

There are two ways to declare varibles. 1. Locally 2. Globally When you declare a variable locally in any function that means it is only accessible by that function. When you declare a variable globally so it is accessible by all the functions in the program. Declaring variables with static keyword means you are setting its value null.


Write a program to revrse the given integer and print it backwords?

In Java, you might use the StringBuffer class. Convert the integer to a StringBuffer, use the method to revert it - I believe it is revert() or something; look it up in the documentation - then print it.In Java, you might use the StringBuffer class. Convert the integer to a StringBuffer, use the method to revert it - I believe it is revert() or something; look it up in the documentation - then print it.In Java, you might use the StringBuffer class. Convert the integer to a StringBuffer, use the method to revert it - I believe it is revert() or something; look it up in the documentation - then print it.In Java, you might use the StringBuffer class. Convert the integer to a StringBuffer, use the method to revert it - I believe it is revert() or something; look it up in the documentation - then print it.


What is the uno keyword?

The "uno" keyword is used in programming languages like Java to declare a variable that can only be assigned a value once. This helps ensure that the variable's value remains constant throughout the program.


What is uses of const and volatile?

When you declare a const you provide a guarantee to the compiler that the value will never be changed by your program; the value is constant. All constants are implicitly static, so they are always allocated in the program's data segment rather than on the stack. When you declare a variable as being volatile, you are stating to the compiler that the memory referred to by that variable is not under the direct control of your program and that external processes may change the value at any time.


I am using Borland C compiler and making a program using switch cases while loading program I'm getting error that case bypasses initialization of a local variable case 4?

You cannot declare variables inside a case label. Declare them outside of the switch.


When you declare an variable in c language where it will be stored in the computer?

Nowhere, variables exist only during the program run. If you want permanent storage, use files.


In c plus plus are local declarations visible to the function in a program?

If you declare a variable inside of any fuction (except main) it will not be available to other functions.


What is the difference between linker and linkage?

linker: linker is used to change an object code into an executable code by linking together the necessary built in functions. linkage: the place where we used to declare a variable of a program is called the linkage of a variable.