Difference between '\t' and "\t"

what is the difference between ‘\t’ and "\t " as they both have produced same output ?
System.out.println(“hello” +’\t’+“world”);
System.out.println(“hello “+”\t”+“world”);

Hi Mansi

For the statement

System.out.println(“hello “+”\t”+“world”);

I think the result is self-explanatory because all the input values are of string type, so the result is also a string.

Coming to the second statement,
System.out.println(“hello” +’\t’+“world”);

Now we have both string and character in this. But since the priority of string is higher, the char gets converted into the string as well. Hence the output is a string similar to the previous statement.

Similarly, if there had been integer instead of char in the statement, it would have been converted into string as well because of the higher priority of string.

Hi Mansi
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.