DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Posts
    2

    I really need help: I cannot figure out the difference between println and print

    Hi,
    The teacher asks me to use both methods System.out.println ( )and System.out.print ( ) but I only see that they are the same. I have just worked out with Java for a few days and I really need help. I appreciate your help a lot. Thank you so much.
    My sample code:
    public class Question4{//The class name
    public static void main(String[]args){ //method name
    System.out.println(new String("This is my first try"));
    System.out.println();//The blank line
    System.out.println(new String("at programming in Java"));
    System.out.println();//The blank line
    System.out.println("It's fun!");

  2. #2
    Join Date
    Feb 2006
    Posts
    11
    I suggest playing with them a bit to see how they behave.

    System.out.print("test print. ");
    System.out.println("test println.");
    System.out.print("test print with newline.\n");
    System.out.println("test println with newline.\n");
    System.out.println("--END OF TEST--");

    Try this, and it will give you the answer.

  3. #3
    Join Date
    Dec 2005
    Location
    New Jersey
    Posts
    290
    Everything you need to know about methods are in the API. The println and print methods are in the url=http://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintStream.html]PrintStream[/url] (out is an instance of PrintStream).

  4. #4
    Join Date
    Jan 2006
    Posts
    10
    System.out.print() Prints everything across
    System.out.println() Prints everything skipping a space

    For example:
    Code:
    System.out.println("OOH, FISH");
    System.out.println("Bye fish");
    Code:
    System.out.print("OOH, FISH");
    System.out.print("Bye fish");
    Output:
    Code:
    OOH, FISH
    Bye fish
    Code:
    OOH, Fish Bye fish
    Absit invidia

Similar Threads

  1. print or println
    By alberto in forum Java
    Replies: 2
    Last Post: 11-20-2000, 09:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links