Can anyone explain me how the System.out.println() prints in the
console. How it process internally to print the string value in the
console.
Thanking you,
manoj
System.out and System.err to the console window. So this is manged by jvm only. System is a final class and out is a static PrintStream object of System class. The methods println() and print() are defined in PrintStream class. The method print takes object as the argument and println is overloaded to handle both primitives and objects. By using certain mechanisam you can forward the stdout to your own file. I did explained it as u've described but they asked me how
it internally does that, which i don't have any idea ab't that.
Regards,
manoj
I told them that System is a final class and out is an
object and println() is a method in PrintStream. But i don't know what
he wanted or may be the explanation like what u've already given.
Regards,
manoj
Regards
Sreehari
On Feb 18, 6:39 pm, Rejin Chandran <reji...@gmail.com> wrote:
> As per my knowledge standarout is done by JVM only and i don't know how it
> is handled in that
> ;-)
>
> On 2/18/10, manoj patel <manoja.pa...@gmail.com> wrote:
>
>
>
>
>
> > Hi Rejin
>
> > I told them that System is a final class and out is an
> > object and println() is a method in PrintStream. But i don't know what
> > he wanted or may be the explanation like what u've already given.
>
> > Regards,
> > manoj
>
> > On Thu, Feb 18, 2010 at 5:53 PM, Rejin Chandran <reji...@gmail.com> wrote:
> > > What you explained to them ? tell me in your own words.
>
> > > On 2/18/10, manoj patel <manoja.pa...@gmail.com> wrote:
>
> > >> hi Rejin
>
> > >> I did explained it as u've described but they asked me how
> > >> it internally does that, which i don't have any idea ab't that.
>
> > >> Regards,
> > >> manoj
>
> > >> On Thu, Feb 18, 2010 at 1:58 PM, Rejin Chandran <reji...@gmail.com>
> > wrote:
> > >> > Java Console is a simple debugging mechanism that redirects any
> > >> > System.out
> > >> > and System.err to the console window. So this is manged by jvm only.
> > >> > System
> > >> > is a final class and out is a static PrintStream object of System
> > class.
> > >> > The
> > >> > methods println() and print() are defined in PrintStream class. The
> > >> > method
> > >> > print takes object as the argument and println is overloaded to handle
> > >> > both
> > >> > primitives and objects. By using certain mechanisam you can forward
> > the
> > >> > stdout to your own file.
>
> > >> > Thanks and Regards
> > >> > Rejin Chandran R
>
> > >> > On 2/18/10, manoj patel <manoja.pa...@gmail.com> wrote:
>
> > >> >> Hi
>
> > >> >> Can anyone explain me how the System.out.println() prints in the
> > >> >> console. How it process internally to print the string value in the
> > >> >> console.
>
> > >> >> Thanking you,
> > >> >> manoj- Hide quoted text -
>
> - Show quoted text -
Hi hari
I’m sharing some information about println.
In Java applications, a typical way to write a line of output data is:
System.out.println(data)
While executing System.out.println(data),
The data goes to standard “output stream”. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user.
If the output is set to console then the output stream is redirected to PrintStream.
Inside the PrintStream class it has the implementation of these methods
java.io.PrintStream println()
java.io.PrintStream println(boolean)
java.io.PrintStream println(char)
java.io.PrintStream println(char[])
java.io.PrintStream println(double)
java.io.PrintStream println(float)
java.io.PrintStream println(int)
java.io.PrintStream println(long)
java.io.PrintStream println(java.lang.Object)
java.io.PrintStream println(java.lang.String)
Working of println inside PrintStream
-------------------------------------
PrintStream has the ability to print representations of various data values conveniently. PrintStream can be created so as to flush automatically.This means that the flush method is automatically invoked after a byte array is written, that is while a println method is invoked, or a newline character or byte'\n' is written.
Unlike other output streams, PrintStream never throws an IOException (if any exception has occured then that can be tested via the checkError method)
HOW data is written to console
--------------------------------------
First JVM converts data into string. All characters in the string are printed by a PrintStream and are converted into bytes using the platform's default character encoding.
(Just keep in mind that in console, all other data formats are converted to string and then printing it)
Regards,
Honeylal M
AmritaTechnologies