answersLogoWhite

0

Btw, this is a C++ question.

in 'String str', str is an object and most probabily (based on most String implementations) we can use

str = "my name";

int len = str.length();

String s = new String; <== this is something wrong.

it should be

String *s = new String;

here 's' is a pointer and the object is allocated/instanciated by 'new' operator

you can use it

*s = "my name"

int len = s->length()

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

What is difference between System.String and System.StringBuilder classes?

String and StringBuilder classes are used to store string values but the difference in them is that String is immutable (read only) by nature, because a value once assigned to a String object cannot be changed after its creation. When the value in the String object is modified, a new object is created, in memory, with a new value assigned to the String object. On the other hand, the StringBuilder class is mutable, as it occupies the same space even if you change the value. The StringBuilder class is more efficient where you have to perform a large amount of string manipulation.


How can a stack determine if a string is a palindrome?

foreach char in string push on to stack create new string foreach char in string pop off and add to end of new string if new string equals old string palindrome else not palindrome //when you pop off the stack, the characters come off in reverse order, thus you have reversed the original string


How many constructors are there for the string class?

The String class has multiple Constructors. Some of them are: 1. String - new String(String val) 2. Character Array - new String(char[] array) 3. Character Array with index positions - new String(char[] array. int start, int end)


What are the differences between old and new irrigation methods?

t are the difference between old and new irrigation method


How do you scramble a string in java?

Take out one letter, using a random number. Then replace the string with the new string, without the extracted letter. Repeat, until the remaining string has a length of zero. The extracted letters get added to a new string.Take out one letter, using a random number. Then replace the string with the new string, without the extracted letter. Repeat, until the remaining string has a length of zero. The extracted letters get added to a new string.Take out one letter, using a random number. Then replace the string with the new string, without the extracted letter. Repeat, until the remaining string has a length of zero. The extracted letters get added to a new string.Take out one letter, using a random number. Then replace the string with the new string, without the extracted letter. Repeat, until the remaining string has a length of zero. The extracted letters get added to a new string.

Related Questions

What is difference between System.String and System.StringBuilder classes?

String and StringBuilder classes are used to store string values but the difference in them is that String is immutable (read only) by nature, because a value once assigned to a String object cannot be changed after its creation. When the value in the String object is modified, a new object is created, in memory, with a new value assigned to the String object. On the other hand, the StringBuilder class is mutable, as it occupies the same space even if you change the value. The StringBuilder class is more efficient where you have to perform a large amount of string manipulation.


How can a stack determine if a string is a palindrome?

foreach char in string push on to stack create new string foreach char in string pop off and add to end of new string if new string equals old string palindrome else not palindrome //when you pop off the stack, the characters come off in reverse order, thus you have reversed the original string


What is the difference between the mid Atlantic and the new England region?

whats the difference between midAtlantic and new England


What is the difference between traditional banking and modern banking?

difference between modern and traditional banking is


What is the difference between the old broadsheet and the new broadsheet?

The difference is that one of them is old and the other one new.


How do you create a string reference?

String strReference = new String();


What is the time difference between Adelaide and New York city?

Difference in local time in Adelaide and Singapore


What are the difference between Karachi and New York?

similarities and differences between new York and Karachi


What is the difference between New York and Chennai?

9 . 5 hrs is the difference


What is the difference between bone China and new bone China?

The difference is the spelling.


What is the time difference between NY and RI?

There is never a time difference between New York and Rhode Island.


What is the time difference between NYC and SF?

The time difference between New York and California is 3 hours.