drevon315 drevon315
  • 03-10-2019
  • Computers and Technology
contestada

Where is the error in this code sequence?

String s1 = "Hello";

String s2 = "ello";

String s = s1-s2;

java programming

Respuesta :

SerenaBochenek SerenaBochenek
  • 05-10-2019

Answer:

There is an error in "String s=s1-s2 ";

Explanation:

In java programming, we can subtract subtract two strings variable with "-" operator.Java programming does not  support an overload of the '-' operator.In java, we can use only "+" operator to append two strings variable.There is no such method to subtract strings in java.Therefore in the given code String s=s1-s2 will give an "bad operand type" error because we can not subtract one string variable from the second string variable.

Answer Link

Otras preguntas

Blood travels away from the heart through which vessels?A. veins->venules-> capillaries->arterioles->arteries->back toward the heartB. arteries-&
HELPPPPPPPPPP PLEASEEEEEEEE!!!!!!
How is your guys day? :D
Let f(x) = -3x -3 and g(x) = -x +7 Find f(g(x)) Find g(f(x))
What is the product of (4x + 2) and (3x - 1)?
Let s(t)=−2t²+2t+8 where s represents the position (displacement), at time t, of an object moving on a straight line, where t is measured in seconds. Consider s
PLEASE HELP Use the image of the rectangular prism to find the surface area. Round your answer to the nearest hundredth.​
When an agent of an investment adviser prepares a client balance sheet, which of the following is a personal possession?A. residenceB. furnitureC. checking acco
Helpppppppppppppppppp
How many officers make up the current Directorate? Listen their names and positions.