Telegram Group & Telegram Channel
Что выведет этот код на Java?


public class Main {
public static void main(String[] args) {
String a = "hello";
String b = "he" + "llo";
String c = "he";
String d = c + "llo";

System.out.println(a == b); // #1
System.out.println(a == d); // #2
System.out.println(a.equals(d)); // #3
}
}


🔢 Варианты ответа:

A)

true
true


B)

false
true


C)

false
true


D)

false
false


Правильный ответ: B

💡 Почему?
- Строки в Java — immutable и используют string pool.
-
a == btrue, потому что "he" + "llo" конкатенируется на этапе компиляции.
-
c + "llo" — создаёт новый объект во время выполнения.
-
a == dfalse, но a.equals(d)true, потому что .equals() сравнивает содержимое строк.

@javatg



tg-me.com/javatg/1802
Create:
Last Update:

Что выведет этот код на Java?


public class Main {
public static void main(String[] args) {
String a = "hello";
String b = "he" + "llo";
String c = "he";
String d = c + "llo";

System.out.println(a == b); // #1
System.out.println(a == d); // #2
System.out.println(a.equals(d)); // #3
}
}


🔢 Варианты ответа:

A)

true
true


B)

false
true


C)

false
true


D)

false
false


Правильный ответ: B

💡 Почему?
- Строки в Java — immutable и используют string pool.
-
a == btrue, потому что "he" + "llo" конкатенируется на этапе компиляции.
-
c + "llo" — создаёт новый объект во время выполнения.
-
a == dfalse, но a.equals(d)true, потому что .equals() сравнивает содержимое строк.

@javatg

BY Java


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/javatg/1802

View MORE
Open in Telegram


Java Telegram | DID YOU KNOW?

Date: |

The S&P 500 slumped 1.8% on Monday and Tuesday, thanks to China Evergrande, the Chinese property company that looks like it is ready to default on its more-than $300 billion in debt. Cries of the next Lehman Brothers—or maybe the next Silverado?—echoed through the canyons of Wall Street as investors prepared for the worst.

Telegram Be The Next Best SPAC

I have no inside knowledge of a potential stock listing of the popular anti-Whatsapp messaging app, Telegram. But I know this much, judging by most people I talk to, especially crypto investors, if Telegram ever went public, people would gobble it up. I know I would. I’m waiting for it. So is Sergei Sergienko, who claims he owns $800,000 of Telegram’s pre-initial coin offering (ICO) tokens. “If Telegram does a SPAC IPO, there would be demand for this issue. It would probably outstrip the interest we saw during the ICO. Why? Because as of right now Telegram looks like a liberal application that can accept anyone - right after WhatsApp and others have turn on the censorship,” he says.

Java from ua


Telegram Java
FROM USA