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

Which of the following functions is most likely to have the smallest value for yifx is large? (Assume & is positive) O a direct variation function with a sm
What is the largest known number called?
What is the term for the type of venation seen on a ginkgo tree? Help meeeee
In this type of governance the power is in the hands of one person​
what is a good question for me to ask that i can put up for 100 points?
A one-day pass to an amusement park costs $40. A round-trip bus ticket to the park costs $5. Write two equivalent expressions to find the total cost of a one-da
Any gîrls here free to talk
How can you use an equation to make a prediction from a pattern?
To apply for a job at the new store in the mole. is this a fragmentation sentence ​
what is 50+60 i need help