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 6904645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:05:13+00:00 2026-05-27T08:05:13+00:00

Can anyone explain, what exactly happens in the following line? java.lang.System.out.print(string + i); It

  • 0

Can anyone explain, what exactly happens in the following line?

java.lang.System.out.print("string" + i);

It will print “string” followed immediately by value of integer i, but what is happening here?

What is the significance of every part of this line?

  • 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-05-27T08:05:14+00:00Added an answer on May 27, 2026 at 8:05 am

    java.lang is the package, which isn’t needed with the correct import statement. System is a class in the java.lang package. out is a static public field (requires no bound instance, like a global variable) in the System class which has type PrintStream.

    A PrintStream adds functionality to another output stream, namely the
    ability to print representations of various data values conveniently.
    Two other features are provided as well. Unlike other output streams,
    a PrintStream never throws an IOException; instead, exceptional
    situations merely set an internal flag that can be tested via the
    checkError method. Optionally, a PrintStream can be created so as to
    flush automatically; this means that the flush method is automatically
    invoked after a byte array is written, one of the println methods is
    invoked, or a newline character or byte (‘\n’) is written.

    This PrintStream is connected behind the scenes to an OutputStream which can either be connected to IDE output or console output (via Java Native Interface).

    The arguments to the print method "string" + i are concatenated using the + operator into a big string, which can be directly fed to the print method. i is a primitive int type so is temporarily converted in memory to String during concatenation. As for string concatenation optimisation behind the scenes:

    An implementation may choose to perform conversion and concatenation in one step to avoid creating and then discarding an
    intermediate String object. To increase the performance of repeated
    string concatenation, a Java compiler may use the StringBuffer class
    (§20.13) or a similar technique to reduce the number of intermediate
    String objects that are created by evaluation of an expression.

    For primitive objects, an implementation may also optimize away the creation of a wrapper object by converting directly from a
    primitive type to a string.

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

Sidebar

Related Questions

Can anyone please explain exactly how the following code works, line by line. I'm
Can anyone explain in a clear way the practical differences between the java.lang.annotation.RetentionPolicy constants
Can anyone explain exactly why Method 1 in the following code does not alter
Can anyone explain exactly how the Strategy Pattern relates to Inversion of Control?
Can anyone explain why following code won't compile? At least on g++ 4.2.4. And
Can anyone explain what the jquery documentation is exactly referring to with this statement:
Can anyone explain me briefly what exactly is component programming in .NET and why
can anyone explain me these codes what are they doing exactly? I could not
Can anyone explain how compilation works? I can't seem to figure out how compilation
Can anyone explain why I get the following errors when compiling the code shown

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.