Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8310667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:32:39+00:00 2026-06-08T19:32:39+00:00

I have refernced the following links What is String pool in Java? Garbage collection

  • 0

I have refernced the following links

What is String pool in Java?

Garbage collection and Strings

http://www.xyzws.com/Javafaq/what-is-string-literal-pool/3

Questions about Java's String pool

Still have some doubts please help me

            `public class StrPool
             { 
               public static void main(String[] args)
               { 
                String abc="hello";
                String abcd="hello";
                System.out.println(abc==abcd);
               }
             }
             `

In the above example OP : true

So we can confirm that both object are refered from same String object Am clear about that.

    `String abc="hello World";
     String abcd="hello";
     System.out.println(abc==abcd);`

This gives output : false

So String pool is carried out when two String object having same literal???

If So two object of String will created in String pool??

Why second output is false ???

I READ THAT String class is immutable

abc and abcd have different object reference then Immutable means

” First String object will created by JVM and give two reference to abc and abcd ” Am i right???

Thank you very much……..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:32:45+00:00Added an answer on June 8, 2026 at 7:32 pm

    The second output is false as both the string abc and abcd having different content(text)

    yes as you said String class is immutable ie their content does not gets changed, if in case you change the string text then JVM will allocate a new space instead of altering it.

    Now when you create a new String reference with some text at that time JVM will check if that text already exists in pool and if then will refer your string to that text or else will create new text within pool

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following references to jquery on my page: <link href=http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css rel=stylesheet type=text/css/>
Consider the following situation: I want to replace links in a string, specifically I
I have the following code: CATextLayer *test = [CATextLayer layer]; test.string = summary; test.wrapped
I have the following code snippet.. I get the error Expected identifier, string or
I have following lines of code to compare String. str1 not equal to str2
I've been given the following regex expression: if (preg_match_all('(http://)?(www[.])?(youtube|vimeo)[^\s]+'is,$prova,$n)) { foreach ($n[3] as $key
I have a Logger class which is expecting a std::string in the following way:
We mostly tend to following the above best practice. Have a look at String
I have the following method: public MethodInfo FancyGetMethodInfo (object obj, string methodName, Type[] methodSignature)
I have the following code: #include <iostream> #include <string> #include <iomanip> #include <locale> #include

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.