Asked by anonymous
What is the value in the variables x, y, and z after the following statements execute (assume each variable below has already been declared)?
str = "the Bluenose in the sun";
x = str.substring(4, str.indexOf("in"));
y = x.length();
z = x.charAt(4);
find the answers for the questions below:
Value of x:
Value of y:
Value of z:
str = "the Bluenose in the sun";
x = str.substring(4, str.indexOf("in"));
y = x.length();
z = x.charAt(4);
find the answers for the questions below:
Value of x:
Value of y:
Value of z:
Answers
Answered by
oobleck
read the documentation of str.substring, and things should be clear.
Remember that strings are indexed starting at zero.
There are lots of examples online. See what you come up with.
Remember that strings are indexed starting at zero.
There are lots of examples online. See what you come up with.
Answered by
anonymous
for x, i got: Bluenose
for y, i got: 9
for z, i got: 110
my assignment says that x, y and z is wrong. but i copied it this java program in my java editor and and it gave x = Bluenose, y =9 and z= 110
for y, i got: 9
for z, i got: 110
my assignment says that x, y and z is wrong. but i copied it this java program in my java editor and and it gave x = Bluenose, y =9 and z= 110
Answered by
oobleck
for x, you will also get the trailing space
y is correct, oddly enough, since the length of "Bluenose" is only 8.
z is a char, not an int
y is correct, oddly enough, since the length of "Bluenose" is only 8.
z is a char, not an int
Answered by
anonymous
thanks oobleck
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.