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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:59:09+00:00 2026-05-31T22:59:09+00:00

I was creating a logger in my java-app (with NetBeans as IDE) when suddenly

  • 0

I was creating a logger in my java-app (with NetBeans as IDE) when suddenly I saw a warning saying: “Inefficient use of string concatenation in logger”.

My oringinal code is

srcLogger.getLogger().log(Level.INFO,"UploadBean.doUpload completado [" + file.getName() + "]\n");

but NetBeans suggested to convert it to a template (what a “template” means here?) giving this code:

srcLogger.getLogger().log(Level.INFO, "UploadBean.doUpload completado [{0}]\n", file.getName());

What’s the different between these two ways of concatenation, I never used the latter though.

Cheers.

  • 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-31T22:59:11+00:00Added an answer on May 31, 2026 at 10:59 pm

    I’d ignore the warning (and switch if it off, if possible). The concatenation is not that inefficient, because modern compilers replace it with an efficient implementation based on StringBuilder (you’ll see it if you look at the classfile’s bytecode).

    The suggested replacement doesn’t concatenate Strings but it requires some extra processing to parse the template and merge it with the parameters.

    Netbeans, that’s a bad advice.

    This is true for Java 1.5+. Older versions of Java (may) create a lot of unused String instances during concatenation..

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

Sidebar

Related Questions

I am creating a logger in java by executing the following code: private static
Creating a server-side socket will fail if I'm trying to use the same port
I am creating a Java EE web service application. I am not sure on
So I have an ArrayList in java. And what I'm doing is creating a
I decided to use Log4J logging framework for a new Java project. I am
I want to inherit to extend java.util.logging.Logger . The only visible constructor is protected
I've created a 2 dimensional 'grid' for a game world I'm creating in Java.
I'm creating a key logger in vb 2008 for my home computer that can
I am new to Java Swing. I am creating a frame with some components.
We're creating a Java client to interface with a Ruby on Rails server for

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.