Ask Question
30 July, 16:02

Where is the error in this code sequence?

String s1 = "Hello";

String s2 = "ello";

String s = s1-s2;

java programming

+1
Answers (1)
  1. 30 July, 16:08
    0
    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Where is the error in this code sequence? String s1 = "Hello"; String s2 = "ello"; String s = s1-s2; java programming ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers