System.out.println in java

In this post, we will see about System.out.println in java and how it works.

Did you use system.out.println before? I think this is first statement every java developer compiles. It is generally called by the acronym "SOP".


What is System.out.println?

System.out.println is Java statement which prints argument passed to console.

System is a class
out is static object of type PrintStream.
println is a method

Let’s go through more details.

System: System is class in the package "java.lang".Since java.lang package is imported into in every program by default,so java.lang package does not require an explicit import statement.

out: out is static member of System class and is an instance of java.io.PrintStream.Internally out object is connected to standard output stream of operating system, so any argument passed to out object goes to OS output stream.

println: println is method of PrintStream class.This method is overloaded to print message to output which is generally console or file.

So you can imagine structure as below.


Does System.out.println impact performance?

Yes, System.out.println can impact performance if overused. When you call println, it internally calls write() and newLine(). Both write and newLine contain synchronized but have little overhead.

If multiple threads write at the same time, then performance can suffer but major cost is to add character to buffer and print them.

In any case, you should not have any System.out.println in the production environment.

That’s all about System.out.println in java.

Related Posts

  • 22 October

    How is java distributed

    Table of ContentsIntroductionFeatures of Java Distributed System and Programing Language Java is a distributed language. Extended Libraries Integration of New Technology JVM (Java Virtual Machine) Networking SupportConclusion Introduction Java is considered to be the most secure platform and programming language. Java was developed in 1995 by Sun Microsystems. It is the most commonly used language […]

  • 26 March

    Java boolean default value

    In this post, we will see what is default value of boolean and Boolean in java. 💡 Did you know? The Default value of boolean is false and wrapper class Boolean is null. Here is the example to demonstrate the same. [crayon-60cb8753910bb950858833/] Output: Default value of boolean: false Default value of Boolean(Wrapper): null As you […]

  • 22 December

    Caesar Cipher in Java

    Table of ContentsAlgorithmImplementationStep 1(Mapping Plaintext) : Step 2(Encrypting and Obtaining CipherText) : Step 3(Decrypting and Obtaining our original Text) : In this post, we will see about Caesar Cipher in Java. In cryptography, we used to study different algorithms or techniques to encrypt and decrypt a different sets of messages to gain confidentiality, integrity or […]

  • 01 April

    Java float vs double

    Table of ContentsJava float vs doubleWhen to use float and double In this post, we will see the difference between float and double data types in java. As you might know, float and double both can be used to represent floating point number in java. We will see the difference between float and double and […]

  • 28 October

    How to take input from user in java

    Table of ContentsUsing  Scanner classUsing  BufferedReader classs In this post, we will see how to take input from user in java. There are times when you want to take input from user and run program according to user input. There are many ways to take input from user and some of them are: Using Scanner […]

  • 28 September

    Top 5 online programming courses you can take to improve your career

    Table of Contents1.Java Training Course2. Angular Certification Training Course3. Node.js Certification Training4. Full Stack Web Developer – MEAN Stack5. Selenium Certification Training CourseTo Wrap it up The beauty of programming is that you are as good as your programming skills. Learning programming languages hold many benefits. Programmers are highly sought out and their skills are […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.