Skip to main content

The second simple program in java

Second simple program in java

                    In this post, we will discuss about the difference between println() and print()

println():
                  println() method shows the text as it is on the screen which is provided in println() method, which is followed by a new line. The cursor goes to the next line.


print():
                 print() method shows the text as it is on the screen which is provided in print() method, which is not followed by a new line. The cursor is still on the same line and not goes to the next line.


Following is the example, which helps us to understand the difference
Code:
          

Output:



As discussed above, we can see, the 3rd line contains print() method and 4th line contains println() method. So, after executing 3rd line, 
cursor still on the same line in output and print the 4th line of code on same line. After executing the 4th line, cursor goes to the next line in the terminal. This is the small difference in these methods.
Thanks.

Comments

Popular posts from this blog

Identifiers

Identifiers:                                         A name in java program is called identifier, which can be used for identification purposes. It can be a method name, variable name, class name, or label name . Rules for defining java identifiers: The only allowed characters in java identifiers are a - z, A - Z, 0 - 9, $, and _. If we are using other characters, we will get a compile-time error. Identifiers can't start with digits. Java identifiers are case sensitive. Of course, java is treated as case sensitive programming language. There is no limit for java identifiers but it is not recommended to take too lengthy identifiers. We can't use reserved words as identifiers. All predefined java class name and interface name we can use as identifiers.                     e.g.    ...

Literals

Literals:                 Any constant value which can be assigned to the variable is called literal.     1 . Integer Literals:                                        For integral data types ( byte, short, int, long ), we can specify a literal value in the following base...                         a) Decimal literal (base 10):                                                     Allowed digits are 0 to 9.                               ...

JAVA HISTORY

History of JAVA:                                                                       Java is the  object-oriented, general-purpose programming language developed by  James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, in 1991. Actually, Java was designed for the development of software for electric devices. It took 18 months to run the first version. This language was initially called "Oak", but was renamed as "JAVA" in 1995. Java Features:                              Java has bundles of features, they are as follows:           1) Object-oriented           2) High performance  ...