In java code  What is the output of this code segment:  String s1 = "Hello"; String s2 = new String("Hello"); if (s1 == s2 ) System.out.println("\n (first) Equal");   else System.out.println("\n (first) not Equal"); if (s1.equals(s2) ) System.out.println("\n (second) Equal");   else System.out.println("\n (second) not Equal");

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 15PE
icon
Related questions
Question

In java code 

What is the output of this code segment:
 String s1 = "Hello";
String s2 = new String("Hello");
if (s1 == s2 ) System.out.println("\n (first) Equal"); 
 else System.out.println("\n (first) not Equal");
if (s1.equals(s2) ) System.out.println("\n (second) Equal"); 
 else System.out.println("\n (second) not Equal");

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT