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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:49:29+00:00 2026-05-23T18:49:29+00:00

Let’s say I wanted to print 5 lines. Which is the best method (for

  • 0

Let’s say I wanted to print 5 lines. Which is the best method (for performance and readability).

System.out.println();
System.out.println();
System.out.println();
System.out.println();
System.out.println();

or

System.out.println("\n\n\n\n");

Is it a matter of preference or is one better than the other. It seems like it would save a lot of time using the second method.

  • 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-23T18:49:30+00:00Added an answer on May 23, 2026 at 6:49 pm

    There is a functional difference between the two. The first version outputs line breaks using the platform’s preferred line separator. The second version outputs newline characters, which is likely to be inappropriate on Windows or Mac OS.

    This is more important than any real or imagined performance advantages.


    On the topic of performance, and why everyone seems to be saying “enough already”.

    The performance difference between your two ways of writing that code is likely to be a small number of microseconds, or less. In other words, an end user won’t notice the difference … unless the code is executed millions of times.

    As a general rule, professional software engineers take the view that it is not worth spending time to make something faster if it doesn’t need to be faster. And it is certainly not worth spending the client’s money doing this.

    You should only indulge in micro-optimization if you have clear evidence that there is, or will be a performance problem, and that the code that you are about to optimize is where the real problem is / will be. Time spent optimizing the wrong bit of code is time wasted.

    So how do you know when to optimize?

    • When the application is observably slow when measured against criteria that actually matter.

    And how do you know what to optimize?

    • By running application profilers, and analysing their output to see where the actual performance hotspots and bottlenecks are.

    Performance is not always an unimportant issue. Indeed, for some kinds of software, a design or implementation that doesn’t take account of performance and scalability requirements can be a total disaster. However, most software is not like that.

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

Sidebar

Related Questions

Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I can call a method like this: core::get() . What is the
Let's say I'm making a tool to help epicureans keep track of which delicacies
Let's say an operating system is installed on a computer and a DBMS is
Let's say I have a dataset, which can be neatly classified using weka's J48
Let's say I'm writing a Windows Forms (.NET Framework 3.5) application which shows the
Let's say I dynamically create a timer like this: System.Timers.Timer expirationTimer = new Timer(expiration
Let's say I wanted all nodes whose parent(s) matched some certain condition. Is there
Let's say you create a wizard in an HTML form. One button goes back,
Let's say I'm building a data access layer for an application. Typically I have

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.